Use sizeof() for calculating the buffer size instead of hard-coded values.
This commit is contained in:
parent
a9093e846d
commit
d069140339
@ -224,7 +224,7 @@ file(char *name)
|
||||
args[3] = &arg[3][0];
|
||||
args[4] = &arg[4][0];
|
||||
retval = 0;
|
||||
while(fgets(line, 100, fp) != NULL) {
|
||||
while(fgets(line, sizeof(line), fp) != NULL) {
|
||||
if ((p = strchr(line, '#')) != NULL)
|
||||
*p = '\0';
|
||||
for (p = line; isblank(*p); p++);
|
||||
|
@ -191,7 +191,7 @@ void add_file_to_keep_list(char *filename)
|
||||
usage();
|
||||
}
|
||||
|
||||
while(fgets(symbol, 1024, keepf)) {
|
||||
while(fgets(symbol, sizeof(symbol), keepf)) {
|
||||
len = strlen(symbol);
|
||||
if(len && symbol[len-1] == '\n')
|
||||
symbol[len-1] = '\0';
|
||||
|
@ -382,7 +382,7 @@ show_dialog(struct keymap **km_sorted, int num_keymaps)
|
||||
fp = fopen(tmp_name, "r");
|
||||
if (fp) {
|
||||
char choice[64];
|
||||
if (fgets(choice, 64, fp) != NULL) {
|
||||
if (fgets(choice, sizeof(choice), fp) != NULL) {
|
||||
/* Find key for desc */
|
||||
for (i=0; i<num_keymaps; i++) {
|
||||
if (!strcmp(choice, km_sorted[i]->desc)) {
|
||||
|
@ -351,7 +351,7 @@ read_number(const char *fn)
|
||||
|
||||
if ((fp = fopen(fn, "r")) == NULL)
|
||||
return (0);
|
||||
if (fgets(lin, 80, fp) == NULL) {
|
||||
if (fgets(lin, sizeof(lin), fp) == NULL) {
|
||||
fclose(fp);
|
||||
return (0);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ main( argc, argv )
|
||||
printf( "multicast membership test program; " );
|
||||
printf( "enter ? for list of commands\n" );
|
||||
|
||||
while( fgets( line, 79, stdin ) != NULL )
|
||||
while( fgets( line, sizeof(line) - 1, stdin ) != NULL )
|
||||
{
|
||||
lineptr = line;
|
||||
while( *lineptr == ' ' || *lineptr == '\t' ) ++lineptr;
|
||||
|
@ -333,7 +333,7 @@ file(name)
|
||||
args[3] = &arg[3][0];
|
||||
args[4] = &arg[4][0];
|
||||
retval = 0;
|
||||
while (fgets(line, 100, fp) != NULL) {
|
||||
while (fgets(line, sizeof(line), fp) != NULL) {
|
||||
i = sscanf(line, "%49s %49s %49s %49s %49s",
|
||||
arg[0], arg[1], arg[2], arg[3], arg[4]);
|
||||
if (i < 2) {
|
||||
|
@ -30,7 +30,7 @@ prompt_term(char **termp)
|
||||
|
||||
printf("\nPlease set your TERM variable before running this program.\n");
|
||||
printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
|
||||
fgets(str, 80, stdin); /* Just to make it interactive */
|
||||
fgets(str, sizeof(str), stdin); /* Just to make it interactive */
|
||||
*termp = (char *)"ansi";
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ prompt_term(char **termp, char **termcapp)
|
||||
printf("5 ...................... xterm terminal emulator.\n\n");
|
||||
printf("Your choice: (1-5) ");
|
||||
fflush(stdout);
|
||||
fgets(str, 80, stdin);
|
||||
fgets(str, sizeof(str), stdin);
|
||||
i = str[0] - '0';
|
||||
if (i > 0 && i < 6) {
|
||||
*termp = (char *)lookup[i - 1].term;
|
||||
@ -64,7 +64,7 @@ prompt_term(char **termp, char **termcapp)
|
||||
else {
|
||||
printf("\nPlease set your TERM variable before running this program.\n");
|
||||
printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
|
||||
fgets(str, 80, stdin); /* Just to make it interactive */
|
||||
fgets(str, sizeof(str), stdin); /* Just to make it interactive */
|
||||
*termp = (char *)"ansi";
|
||||
*termcapp = (char *)termcap_ansi;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user