eliminating gcc warning...
Hello all,
I'm trying to eliminate all gcc warnings, which can be obtained by means of using -Wall and -W gcc keys, in linux-2.6.1. I decided, that this should be done step-by-step. And now I have made a patch for scripts directory. See attachment.
If something wrong and someone is so kind to tell me about, I will be very thankful.
Signature · 1 line
umka
linux-2.6.1/scripts/file2alias.c renamed from linux-2.6.1.orig/scripts/file2alias.c +4 -4
@@ -127,10 +127,10 @@ static int do_pci_entry(const char *file id->class_mask =TO_NATIVE (id->class_mask);strcpy (alias,"pci:" ); -ADD (alias,"v" , id->vendor !=PCI_ANY_ID , id->vendor); -ADD (alias,"d" , id->device !=PCI_ANY_ID , id->device); -ADD (alias,"sv" , id->subvendor !=PCI_ANY_ID , id->subvendor); -ADD (alias,"sd" , id->subdevice !=PCI_ANY_ID , id->subdevice); +ADD (alias,"v" , (int )id->vendor !=PCI_ANY_ID , id->vendor); +ADD (alias,"d" , (int )id->device !=PCI_ANY_ID , id->device); +ADD (alias,"sv" , (int )id->subvendor !=PCI_ANY_ID , id->subvendor); +ADD (alias,"sd" , (int )id->subdevice !=PCI_ANY_ID , id->subdevice); baseclass = (id->class) >>16 ; baseclass_mask = (id->class_mask) >>16 ;
linux-2.6.1/scripts/fixdep.c renamed from linux-2.6.1.orig/scripts/fixdep.c +3 -3
@@ -211,9 +211,9 @@ void use_config(char *m, int slen)void parse_config_file (char *map,size_t len) { -int *end = (int *) (map + len); +unsigned int *end = (int *) (map + len);/* start at +1, so that p can never be < map */ -int *m = (int *) map +1 ; +unsigned int *m = (int *) map +1 ;char *p, *q;for (; m < end; m++) {
@@ -356,7 +356,7 @@ void traps(void) { static char test[] __attribute__((aligned(sizeof(int)))) = "CONF"; -if (*(int *)test !=INT_CONF ) { +if (*(unsigned int *)test !=INT_CONF ) {fprintf (stderr,"fixdep: sizeof(int) != 4 or wrong endianess? %#x\n" , *(int *)test);exit (2 );
linux-2.6.1/scripts/genksyms/keywords.c_shipped renamed from linux-2.6.1.orig/scripts/genksyms/keywords.c_shipped +25 -24
95 lines not on this page · raw message
linux-2.6.1/scripts/kconfig/confdata.c renamed from linux-2.6.1.orig/scripts/kconfig/confdata.c +4 -2
@@ -214,12 +214,14 @@ int conf_read(const char *name)case no:break ;case mod: -if (cs->user.tri == yes) +if (cs->user.tri == yes) {/* warn? */ ; + }break ;case yes: -if (cs->user.tri != no) +if (cs->user.tri != no) {/* warn? */ ; + } cs->user.val = sym;break ; }
linux-2.6.1/scripts/kconfig/mconf.c renamed from linux-2.6.1.orig/scripts/kconfig/mconf.c +2 -1
@@ -438,7 +438,8 @@ static void conf(struct menu *menu)const char *prompt =menu_get_prompt (menu);struct symbol *sym;char active_entry[40 ]; -int stat, type, i; +int stat, type; +unsigned int i;unlink ("lxdialog.scrltmp" ); active_entry[0 ] =0 ;
linux-2.6.1/scripts/kconfig/menu.c renamed from linux-2.6.1.orig/scripts/kconfig/menu.c +1 -1
@@ -88,7 +88,7 @@ void menu_set_type(int type) {struct symbol *sym = current_entry->sym; -if (sym->type == type) +if (sym->type == (unsigned int )type)return ;if (sym->type ==S_UNKNOWN ) { sym->type = type;
linux-2.6.1/scripts/lxdialog/checklist.c renamed from linux-2.6.1.orig/scripts/lxdialog/checklist.c +2 -2
@@ -161,7 +161,7 @@ dialog_checklist (const char *title, conwattrset (dialog, dialog_attr);waddch (dialog,ACS_RTEE ); -if (title !=NULL &&strlen (title) >= width-2 ) { +if (title !=NULL &&strlen (title) >= (unsigned int )(width-2 )) {/* truncate long title -- mec */ char * title2 =malloc (width-2 +1 );memcpy ( title2, title, width-2 );
@@ -195,7 +195,7 @@ dialog_checklist (const char *title, con/* Find length of longest item in order to center checklist */ check_x =0 ;for (i =0 ; i < item_no; i++) - check_x =MAX (check_x, +strlen (items[i *3 +1 ]) +4 ); + check_x =MAX ((unsigned int )check_x, +strlen (items[i *3 +1 ]) +4 ); check_x = (list_width - check_x) /2 ; item_x = check_x +4 ;
linux-2.6.1/scripts/lxdialog/inputbox.c renamed from linux-2.6.1.orig/scripts/lxdialog/inputbox.c +1 -1
@@ -69,7 +69,7 @@ dialog_inputbox (const char *title, conswattrset (dialog, dialog_attr);waddch (dialog,ACS_RTEE ); -if (title !=NULL &&strlen (title) >= width-2 ) { +if (title !=NULL &&strlen (title) >= (unsigned int )(width-2 )) {/* truncate long title -- mec */ char * title2 =malloc (width-2 +1 );memcpy ( title2, title, width-2 );
linux-2.6.1/scripts/lxdialog/menubox.c renamed from linux-2.6.1.orig/scripts/lxdialog/menubox.c +2 -2
@@ -193,7 +193,7 @@ dialog_menu (const char *title, const chwbkgdset (dialog, dialog_attr &A_COLOR );waddch (dialog,ACS_RTEE ); -if (title !=NULL &&strlen (title) >= width-2 ) { +if (title !=NULL &&strlen (title) >= (unsigned int )(width-2 )) {/* truncate long title -- mec */ char * title2 =malloc (width-2 +1 );memcpy ( title2, title, width-2 );
@@ -230,7 +230,7 @@ dialog_menu (const char *title, const ch*/ item_x =0 ;for (i =0 ; i < item_no; i++) { - item_x =MAX (item_x,MIN (menu_width,strlen (items[i *2 +1 ]) +2 )); + item_x =MAX ((unsigned int )item_x,MIN ((unsigned int )menu_width,strlen (items[i *2 +1 ]) +2 ));if (strcmp (current, items[i*2 ]) ==0 ) choice = i; }
linux-2.6.1/scripts/lxdialog/msgbox.c renamed from linux-2.6.1.orig/scripts/lxdialog/msgbox.c +1 -1
@@ -43,7 +43,7 @@ dialog_msgbox (const char *title, constdraw_box (dialog,0 ,0 , height, width, dialog_attr, border_attr); -if (title !=NULL &&strlen (title) >= width-2 ) { +if (title !=NULL &&strlen (title) >= (unsigned int )(width-2 )) {/* truncate long title -- mec */ char * title2 =malloc (width-2 +1 );memcpy ( title2, title, width-2 );
linux-2.6.1/scripts/lxdialog/textbox.c renamed from linux-2.6.1.orig/scripts/lxdialog/textbox.c +3 -3
@@ -106,7 +106,7 @@ dialog_textbox (const char *title, constwbkgdset (dialog, dialog_attr &A_COLOR );waddch (dialog,ACS_RTEE ); -if (title !=NULL &&strlen (title) >= width-2 ) { +if (title !=NULL &&strlen (title) >= (unsigned int )(width-2 )) {/* truncate long title -- mec */ char * title2 =malloc (width-2 +1 );memcpy ( title2, title, width-2 );
@@ -463,10 +463,10 @@ print_line (WINDOW * win, int row, int wchar *line; line =get_line (); - line +=MIN (strlen (line), hscroll);/* Scroll horizontally */ + line +=MIN (strlen (line), (unsigned int )hscroll);/* Scroll horizontally */ wmove (win, row,0 );/* move cursor to correct line */ waddch (win,' ' ); -waddnstr (win, line,MIN (strlen (line), width -2 )); +waddnstr (win, line,MIN (strlen (line), (unsigned int )(width -2 )));getyx (win, y, x);/* Clear 'residue' of previous line */
linux-2.6.1/scripts/lxdialog/util.c renamed from linux-2.6.1.orig/scripts/lxdialog/util.c +3 -2
@@ -231,7 +231,7 @@ print_autowrap (WINDOW * win, const char room = width - cur_x; wlen =strlen (word);if (wlen > room || - (newl && wlen <4 && sp && wlen+1 +strlen (sp) > room + (newl && wlen <4 && sp && wlen+1 +(int )strlen (sp) > room && (!(sp2 =index (sp,' ' )) || wlen+1 +(sp2-sp) > room))) { cur_y++; cur_x = x;
@@ -342,7 +342,8 @@ draw_shadow (WINDOW * win, int y, int x,int first_alpha (const char *string,const char *exempt) { -int i, in_paren=0 , c; +int in_paren=0 , c; +unsigned int i;for (i =0 ; i <strlen (string); i++) { c =tolower (string[i]);
linux-2.6.1/scripts/lxdialog/yesno.c renamed from linux-2.6.1.orig/scripts/lxdialog/yesno.c +1 -1
@@ -63,7 +63,7 @@ dialog_yesno (const char *title, const cwattrset (dialog, dialog_attr);waddch (dialog,ACS_RTEE ); -if (title !=NULL &&strlen (title) >= width-2 ) { +if (title !=NULL &&strlen (title) >= (unsigned int )(width-2 )) {/* truncate long title -- mec */ char * title2 =malloc (width-2 +1 );memcpy ( title2, title, width-2 );
linux-2.6.1/scripts/modpost.c renamed from linux-2.6.1.orig/scripts/modpost.c +6 -4
@@ -342,7 +342,7 @@ read_symbols(char *modname) {const char *symname;struct module *mod; -struct elf_info info = { }; +struct elf_info info;struct symbol *s;Elf_Sym *sym;
@@ -350,6 +350,7 @@ read_symbols(char *modname)* unresolved symbols (since there'll be too many ;) */ have_vmlinux =is_vmlinux (modname); +memset (&info,0 ,sizeof (info));parse_elf (&info, modname); mod =new_module (modname);
@@ -513,7 +514,7 @@ write_if_changed(struct buffer *b, const goto close_write; tmp =NOFAIL (malloc (b->pos)); -if (fread (tmp,1 , b->pos, file) != b->pos) +if (fread (tmp,1 , b->pos, file) != (unsigned int )b->pos) goto free_write;if (memcmp (tmp, b->p, b->pos) !=0 )
@@ -533,7 +534,7 @@ write_if_changed(struct buffer *b, constperror (fname);exit (1 ); } -if (fwrite (b->p,1 , b->pos, file) != b->pos) { +if (fwrite (b->p,1 , b->pos, file) != (unsigned int )b->pos) {perror (fname);exit (1 ); }
@@ -544,9 +545,10 @@ int main(int argc, char **argv) { struct module *mod; -struct buffer buf = { }; +struct buffer buf;char fname[SZ ]; +memset (&buf,0 ,sizeof (buf));for (; argv[1 ]; argv++) {read_symbols (argv[1 ]); }
Quoted 10 lines · Yury V. Umanets
Hello all,
I'm trying to eliminate all gcc warnings, which can be obtained by means of using -Wall and -W gcc keys, in linux-2.6.1. I decided, that this should be done step-by-step. And now I have made a patch for scripts directory. See attachment.
If something wrong and someone is so kind to tell me about, I will be very thankful.
I'm doing a similar thing, and there's been quite a lot of discussion about patches of this sort.
You should read the threads with these titles that have been active for the last few days :
"Suspected bug infilesystems (UFS,ADFS,BEFS,BFS,ReiserFS) related to sector_t being unsigned, advice requested" "[PATCH] mm/slab.c remove impossible <0 check - size_t is not signed - patch is against 2.6.1-rc1-mm2" "[PATCH] fs/fcntl.c - remove impossible <0 check in do_fcntl - arg is unsigned." "[PATCH][RFC] variable size and signedness issues in ldt.c - potential problem?"
"Cleanup patches - comparison is always [true|false] + unsigned/signed compare, and similar issues"
A lot of good comments have been made by various people in those threads about what type of patches are wanted and what type of patches are not wanted. Also some comments on what kind of warnings not to bother with (and why) have been made.
May I suggest that we maybe work together on this instead of duplicating eachothers effort?
If you think that cooperating on this is a good idea, then feel free to email me privately and let's talk about how to split the task between us.
-- Jesper Juhl
Quoted 16 lines · Jesper Juhl
Quoted 10 lines · Yury V. Umanets
Hello all,
I'm trying to eliminate all gcc warnings, which can be obtained by means of using -Wall and -W gcc keys, in linux-2.6.1. I decided, that this should be done step-by-step. And now I have made a patch for scripts directory. See attachment.
If something wrong and someone is so kind to tell me about, I will be very thankful.
I'm doing a similar thing, and there's been quite a lot of discussion about patches of this sort.
Quoted 9 lines
You should read the threads with these titles that have been active for the last few days :
"Suspected bug infilesystems (UFS,ADFS,BEFS,BFS,ReiserFS) related to
sector_tbeing unsigned, advice requested" "[PATCH]mm/slab.cremove impossible <0 check -size_tis not signed - patch is against 2.6.1-rc1-mm2" "[PATCH]fs/fcntl.c- remove impossible <0 check indo_fcntl- arg is unsigned." "[PATCH][RFC] variable size and signedness issues inldt.c- potential problem?"
"Cleanup patches - comparison is always [true|false] + unsigned/signed compare, and similar issues"
Hello Jesper,
I have read you emails about UFS,ADFS,BEFS,BFS,ReiserFS, etc. earlier and I want to support your efforts.
Quoted 4 lines
A lot of good comments have been made by various people in those threads about what type of patches are wanted and what type of patches are not wanted. Also some comments on what kind of warnings not to bother with (and why) have been made.
Ok, I will read also other threads. Nevertheless I don't like warnings at all, doing this my point was to try to find out if some warnings point to possible bugs. I have found something already in fs/smbfs/inode.c -- using SET_UID() with 16 bit values.
Quoted 2 lines
May I suggest that we maybe work together on this instead of duplicating eachothers effort?
ok, what would be nice.
Quoted 2 lines
If you think that cooperating on this is a good idea, then feel free to email me privately and let's talk about how to split the task between us.
ok, I will, thanks.
Quoted 3 lines
-- Jesper Juhl
Signature · 1 line
umka