bin/127986: [ee] [patch] fix compiler warnings caused by use of
NULL instead of '\0'
Bruce Cran
bruce at cran.org.uk
Fri Oct 10 02:00:12 UTC 2008
>Number: 127986
>Category: bin
>Synopsis: [ee] [patch] fix compiler warnings caused by use of NULL instead of '\0'
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Oct 10 02:00:04 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator: Bruce Cran
>Release: 8.0-CURRENT
>Organization:
>Environment:
FreeBSD gluon.draftnet 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sun Oct 5 05:17:09 BST 2008 brucec at gluon.draftnet:/usr/obj/usr/src/sys/GENERIC i386
>Description:
During a buildworld, the compilation of ee.c produces lots of warnings of "cast from pointer to integer of different size". These are produced because NULL is used where '\0' (nul) should have been used instead. The attached patch fixes the warnings by changing NULL to '\0'; it also removes a few unneeded casts.
>How-To-Repeat:
cd /usr/src/usr.bin/ee && make
>Fix:
Patch attached with submission follows:
--- ee.c.orig 2006-01-11 08:01:32.000000000 +0000
+++ ee.c 2008-10-10 02:39:50.000000000 +0100
@@ -557,7 +557,7 @@
d_char = malloc(3); /* provide a buffer for multi-byte chars */
d_word = malloc(150);
- *d_word = (char) NULL;
+ *d_word = '\0';
d_line = NULL;
dlt_line = txtalloc();
dlt_line->line = d_line;
@@ -797,7 +797,7 @@
d_char[0] = *point;
d_char[1] = *(point + 1);
}
- d_char[del_width] = (unsigned char) NULL;
+ d_char[del_width] = '\0';
}
while (temp_pos <= curr_line->line_length)
{
@@ -826,7 +826,7 @@
if (in == 8)
{
d_char[0] = '\n';
- d_char[1] = (unsigned char) NULL;
+ d_char[1] = '\0';
}
tp = point;
temp_pos = 1;
@@ -838,7 +838,7 @@
tp++;
temp2++;
}
- *tp = (char) NULL;
+ *tp = '\0';
free(temp_buff->line);
free(temp_buff);
temp_buff = curr_line;
@@ -964,7 +964,7 @@
waddch(window, (unsigned char)character);
return(1);
}
- for (i2 = 0; (string[i2] != (char) NULL) && (((column+i2+1)-horiz_offset) < last_col); i2++)
+ for (i2 = 0; (string[i2] != '\0') && (((column+i2+1)-horiz_offset) < last_col); i2++)
waddch(window, string[i2]);
return(strlen(string));
}
@@ -1089,13 +1089,13 @@
temp++;
}
temp=point;
- *temp = (char) NULL;
+ *temp = '\0';
temp = resiz_line((1 - temp_nod->line_length), curr_line, position);
curr_line->line_length = 1 + temp - curr_line->line;
}
curr_line->line_length = position;
curr_line = temp_nod;
- *extra = (char) NULL;
+ *extra = '\0';
position = 1;
point= curr_line->line;
if (disp)
@@ -1138,9 +1138,9 @@
unsigned char *next_word(string) /* move to next word in string */
unsigned char *string;
{
- while ((*string != (char) NULL) && ((*string != 32) && (*string != 9)))
+ while ((*string != '\0') && ((*string != 32) && (*string != 9)))
string++;
- while ((*string != (char) NULL) && ((*string == 32) || (*string == 9)))
+ while ((*string != '\0') && ((*string == 32) || (*string == 9)))
string++;
return(string);
}
@@ -1174,7 +1174,7 @@
if (in == 1) /* control a */
{
string = get_string(ascii_code_str, TRUE);
- if (*string != (char) NULL)
+ if (*string != '\0')
{
in = atoi(string);
wmove(text_win, scr_vert, (scr_horz - horiz_offset));
@@ -1282,7 +1282,7 @@
else if (in == 15) /* control o */
{
string = get_string(ascii_code_str, TRUE);
- if (*string != (char) NULL)
+ if (*string != '\0')
{
in = atoi(string);
wmove(text_win, scr_vert, (scr_horz - horiz_offset));
@@ -1683,7 +1683,7 @@
return;
}
cmd_str = next_word(cmd_str);
- if (*cmd_str == (char) NULL)
+ if (*cmd_str == '\0')
{
cmd_str = cmd_str2 = get_string(file_write_prompt_str, TRUE);
}
@@ -1699,7 +1699,7 @@
return;
}
cmd_str = next_word(cmd_str);
- if (*cmd_str == (char) NULL)
+ if (*cmd_str == '\0')
{
cmd_str = cmd_str2 = get_string(file_read_prompt_str, TRUE);
}
@@ -1910,9 +1910,9 @@
}
wrefresh(com_win);
if (esc_flag)
- in = (char) NULL;
+ in = '\0';
} while ((in != '\n') && (in != '\r'));
- *nam_str = (char) NULL;
+ *nam_str = '\0';
nam_str = tmp_string;
if (((*nam_str == ' ') || (*nam_str == 9)) && (advance))
nam_str = next_word(nam_str);
@@ -1937,7 +1937,7 @@
strng1 = string1;
strng2 = string2;
tmp = 0;
- if ((strng1 == NULL) || (strng2 == NULL) || (*strng1 == (char) NULL) || (*strng2 == (char) NULL))
+ if ((strng1 == NULL) || (strng2 == NULL) || (*strng1 == '\0') || (*strng2 == '\0'))
return(FALSE);
equal = TRUE;
while (equal)
@@ -1954,7 +1954,7 @@
}
strng1++;
strng2++;
- if ((*strng1 == (char) NULL) || (*strng2 == (char) NULL) || (*strng1 == ' ') || (*strng2 == ' '))
+ if ((*strng1 == '\0') || (*strng2 == '\0') || (*strng1 == ' ') || (*strng2 == ' '))
break;
tmp++;
}
@@ -2110,13 +2110,13 @@
temp_names = temp_names->next_name;
}
ptr = temp_names->name = malloc(strlen(buff) + 1);
- while (*buff != (char) NULL)
+ while (*buff != '\0')
{
*ptr = *buff;
buff++;
ptr++;
}
- *ptr = (char) NULL;
+ *ptr = '\0';
temp_names->next_name = NULL;
input_file = TRUE;
recv_file = TRUE;
@@ -2198,7 +2198,7 @@
wmove(com_win, 0, 0);
wclrtoeol(com_win);
text_changes = TRUE;
- if ((tmp_file != NULL) && (*tmp_file != (char) NULL))
+ if ((tmp_file != NULL) && (*tmp_file != '\0'))
wprintw(com_win, file_read_fin_msg, tmp_file);
}
wrefresh(com_win);
@@ -2322,7 +2322,7 @@
if (tline->next_line != NULL)
tline->next_line->prev_line = tline;
curr_line = tline;
- curr_line->line = point = (unsigned char *) malloc(char_count);
+ curr_line->line = point = malloc(char_count);
curr_line->line_length = char_count;
curr_line->max_length = char_count;
}
@@ -2337,7 +2337,7 @@
point++;
str1++;
}
- *point = (char) NULL;
+ *point = '\0';
*append = FALSE;
if ((num == length) && (*str2 != '\n'))
*append = TRUE;
@@ -2375,10 +2375,10 @@
| portion of file_op()
*/
- if ((file_name == NULL) || (*file_name == (char) NULL))
+ if ((file_name == NULL) || (*file_name == '\0'))
file_name = get_string(save_file_name_prompt, TRUE);
- if ((file_name == NULL) || (*file_name == (char) NULL))
+ if ((file_name == NULL) || (*file_name == '\0'))
{
wmove(com_win, 0, 0);
wprintw(com_win, file_not_saved_msg);
@@ -2463,7 +2463,7 @@
free(curr_line->next_line);
}
curr_line->next_line = NULL;
- *curr_line->line = (char) NULL;
+ *curr_line->line = '\0';
curr_line->line_length = 1;
curr_line->line_number = 1;
point = curr_line->line;
@@ -2555,7 +2555,7 @@
int iter;
int found;
- if ((srch_str == NULL) || (*srch_str == (char) NULL))
+ if ((srch_str == NULL) || (*srch_str == '\0'))
return(FALSE);
if (display_message)
{
@@ -2580,7 +2580,7 @@
if (case_sen) /* if case sensitive */
{
srch_3 = srch_str;
- while ((*srch_2 == *srch_3) && (*srch_3 != (char) NULL))
+ while ((*srch_2 == *srch_3) && (*srch_3 != '\0'))
{
found = TRUE;
srch_2++;
@@ -2590,14 +2590,14 @@
else /* if not case sensitive */
{
srch_3 = u_srch_str;
- while ((toupper(*srch_2) == *srch_3) && (*srch_3 != (char) NULL))
+ while ((toupper(*srch_2) == *srch_3) && (*srch_3 != '\0'))
{
found = TRUE;
srch_2++;
srch_3++;
}
} /* end else */
- if (!((*srch_3 == (char) NULL) && (found)))
+ if (!((*srch_3 == '\0') && (found)))
{
found = FALSE;
if (iter < srch_line->line_length)
@@ -2665,19 +2665,19 @@
{
if (srch_str != NULL)
free(srch_str);
- if ((u_srch_str != NULL) && (*u_srch_str != (char) NULL))
+ if ((u_srch_str != NULL) && (*u_srch_str != '\0'))
free(u_srch_str);
srch_str = get_string(search_prompt_str, FALSE);
gold = FALSE;
srch_3 = srch_str;
srch_1 = u_srch_str = malloc(strlen(srch_str) + 1);
- while (*srch_3 != (char) NULL)
+ while (*srch_3 != '\0')
{
*srch_1 = toupper(*srch_3);
srch_1++;
srch_3++;
}
- *srch_1 = (char) NULL;
+ *srch_1 = '\0';
search(TRUE);
}
@@ -2714,7 +2714,7 @@
{
in = d_char[0];
insert(in);
- if (d_char[1] != (unsigned char) NULL)
+ if (d_char[1] != '\0')
{
in = d_char[1];
insert(in);
@@ -2756,7 +2756,7 @@
d_word2++;
d_word3++;
}
- *d_word2 = (char) NULL;
+ *d_word2 = '\0';
d_wrd_len = difference = d_word2 - d_word;
d_word2 = point;
while (tposit < curr_line->line_length)
@@ -2767,7 +2767,7 @@
d_word3++;
}
curr_line->line_length -= difference;
- *d_word2 = (char) NULL;
+ *d_word2 = '\0';
draw_line(scr_vert, scr_horz,point,position,curr_line->line_length);
d_char[0] = tmp_char[0];
d_char[1] = tmp_char[1];
@@ -2820,7 +2820,7 @@
}
curr_line->line_length += d_wrd_len;
tmp_old_ptr = point;
- *tmp_ptr = (char) NULL;
+ *tmp_ptr = '\0';
tmp_ptr = tmp_space;
tposit = 1;
/*
@@ -2833,7 +2833,7 @@
tmp_ptr++;
tmp_old_ptr++;
}
- *tmp_old_ptr = (char) NULL;
+ *tmp_old_ptr = '\0';
free(tmp_space);
draw_line(scr_vert, scr_horz, point, position, curr_line->line_length);
}
@@ -2859,8 +2859,8 @@
tposit++;
}
dlt_line->line_length = 1 + tposit - position;
- *dl1 = (char) NULL;
- *point = (char) NULL;
+ *dl1 = '\0';
+ *point = '\0';
curr_line->line_length = position;
wclrtoeol(text_win);
if (curr_line->next_line != NULL)
@@ -2895,7 +2895,7 @@
ud1++;
ud2++;
}
- *ud1 = (char) NULL;
+ *ud1 = '\0';
draw_line(scr_vert, scr_horz,point,position,curr_line->line_length);
}
@@ -3041,7 +3041,7 @@
if (!(path = getenv("SHELL")))
path = "/bin/sh";
last_slash = temp_point = path;
- while (*temp_point != (char) NULL)
+ while (*temp_point != '\0')
{
if (*temp_point == '/')
last_slash = ++temp_point;
@@ -3151,7 +3151,7 @@
}
for (value = 1; value < 24; value++)
signal(value, SIG_DFL);
- execl(path, last_slash, "-c", string, (char *)NULL);
+ execl(path, last_slash, "-c", string, NULL);
errx(1, exec_err_msg, path);
}
else /* if the parent */
@@ -3175,7 +3175,7 @@
}
do
{
- return_val = wait((int *) 0);
+ return_val = wait(NULL);
}
while ((return_val != parent) && (return_val != -1));
/*
@@ -3744,9 +3744,9 @@
flag = FALSE;
string = in_file_name;
- if ((string == NULL) || (*string == (char) NULL))
+ if ((string == NULL) || (*string == '\0'))
string = get_string(save_file_name_prompt, TRUE);
- if ((string == NULL) || (*string == (char) NULL))
+ if ((string == NULL) || (*string == '\0'))
{
wmove(com_win, 0, 0);
wprintw(com_win, file_not_saved_msg);
@@ -3781,7 +3781,7 @@
char *string;
if (((string = get_string(shell_prompt, TRUE)) != NULL) &&
- (*string != (char) NULL))
+ (*string != '\0'))
{
sh_command(string);
free(string);
@@ -3901,20 +3901,20 @@
temp_case = case_sen;
case_sen = TRUE;
tmp_srchstr = srch_str;
- temp2 = srch_str = (unsigned char *) malloc(1 + curr_line->line_length - position);
+ temp2 = srch_str = malloc(1 + curr_line->line_length - position);
if ((*point == ' ') || (*point == '\t'))
adv_word();
offset -= position;
counter = position;
line = temp1 = point;
- while ((*temp1 != (char) NULL) && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
+ while ((*temp1 != '\0') && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
{
*temp2 = *temp1;
temp2++;
temp1++;
counter++;
}
- *temp2 = (char) NULL;
+ *temp2 = '\0';
if (position != 1)
bol();
while (!Blank_Line(curr_line->prev_line))
@@ -4108,7 +4108,7 @@
str1 = str2 = string;
while (*str2 != '\n')
str2++;
- *str2 = (char) NULL;
+ *str2 = '\0';
if (unique_test(string, init_strings) != 1)
continue;
@@ -4139,7 +4139,7 @@
else if (compare(str1, Echo, FALSE))
{
str1 = next_word(str1);
- if (*str1 != (char) NULL)
+ if (*str1 != '\0')
echo_string(str1);
}
else if (compare(str1, PRINTCOMMAND, FALSE))
@@ -4263,7 +4263,7 @@
while ((string = fgets(buffer, 512, old_init_file)) != NULL)
{
length = strlen(string);
- string[length - 1] = (char) NULL;
+ string[length - 1] = '\0';
if (unique_test(string, init_strings) == 1)
{
@@ -4310,7 +4310,7 @@
int Counter;
temp = string;
- while (*temp != (char) NULL)
+ while (*temp != '\0')
{
if (*temp == '\\')
{
@@ -4418,7 +4418,7 @@
return(0);
pnt = test_line->line;
- if ((pnt == NULL) || (*pnt == (char) NULL) ||
+ if ((pnt == NULL) || (*pnt == '\0') ||
(*pnt == '.') || (*pnt == '>'))
return(0);
@@ -4427,16 +4427,16 @@
pnt = next_word(pnt);
}
- if (*pnt == (char) NULL)
+ if (*pnt == '\0')
return(0);
counter = 0;
- while ((*pnt != (char) NULL) && ((*pnt != ' ') && (*pnt != '\t')))
+ while ((*pnt != '\0') && ((*pnt != ' ') && (*pnt != '\t')))
{
pnt++;
counter++;
}
- while ((*pnt != (char) NULL) && ((*pnt == ' ') || (*pnt == '\t')))
+ while ((*pnt != '\0') && ((*pnt == ' ') || (*pnt == '\t')))
{
pnt++;
counter++;
@@ -4487,7 +4487,7 @@
d_line = NULL;
auto_format = FALSE;
offset = position;
- if ((position != 1) && ((*point == ' ') || (*point == '\t') || (position == curr_line->line_length) || (*point == (char) NULL)))
+ if ((position != 1) && ((*point == ' ') || (*point == '\t') || (position == curr_line->line_length) || (*point == '\0')))
prev_word();
temp_dword = d_word;
temp_dwl = d_wrd_len;
@@ -4496,20 +4496,20 @@
temp_case = case_sen;
case_sen = TRUE;
tmp_srchstr = srch_str;
- temp2 = srch_str = (unsigned char *) malloc(1 + curr_line->line_length - position);
+ temp2 = srch_str = malloc(1 + curr_line->line_length - position);
if ((*point == ' ') || (*point == '\t'))
adv_word();
offset -= position;
counter = position;
line = temp1 = point;
- while ((*temp1 != (char) NULL) && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
+ while ((*temp1 != '\0') && (*temp1 != ' ') && (*temp1 != '\t') && (counter < curr_line->line_length))
{
*temp2 = *temp1;
temp2++;
temp1++;
counter++;
}
- *temp2 = (char) NULL;
+ *temp2 = '\0';
if (position != 1)
bol();
while (!Blank_Line(curr_line->prev_line))
@@ -4811,9 +4811,9 @@
{
char *full, *sub;
- for (sub = substring; (sub != NULL) && (*sub != (char)NULL); sub++)
+ for (sub = substring; (sub != NULL) && (*sub != '\0'); sub++)
{
- for (full = string; (full != NULL) && (*full != (char)NULL);
+ for (full = string; (full != NULL) && (*full != '\0');
full++)
{
if (*sub == *full)
@@ -4856,7 +4856,7 @@
slash = strchr(name, '/');
if (slash == NULL)
return(name);
- *slash = (char) NULL;
+ *slash = '\0';
user = (struct passwd *) getpwnam((name + 1));
*slash = '/';
}
@@ -4876,10 +4876,10 @@
tmp = buffer;
index = 0;
- while ((*tmp != (char) NULL) && (index < 1024))
+ while ((*tmp != '\0') && (index < 1024))
{
- while ((*tmp != (char) NULL) && (*tmp != '$') &&
+ while ((*tmp != '\0') && (*tmp != '$') &&
(index < 1024))
{
long_buffer[index] = *tmp;
@@ -4895,7 +4895,7 @@
if (*tmp == '{') /* } */ /* bracketed variable name */
{
tmp++; /* { */
- while ((*tmp != (char) NULL) &&
+ while ((*tmp != '\0') &&
(*tmp != '}') &&
(counter < 128))
{
@@ -4908,7 +4908,7 @@
}
else
{
- while ((*tmp != (char) NULL) &&
+ while ((*tmp != '\0') &&
(*tmp != '/') &&
(*tmp != '$') &&
(counter < 128))
@@ -4918,7 +4918,7 @@
tmp++;
}
}
- short_buffer[counter] = (char) NULL;
+ short_buffer[counter] = '\0';
if ((slash = getenv(short_buffer)) != NULL)
{
offset = strlen(slash);
@@ -4941,7 +4941,7 @@
if (index == 1024)
return(buffer);
else
- long_buffer[index] = (char) NULL;
+ long_buffer[index] = '\0';
if (name != buffer)
free(buffer);
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list