write-only variables in src/sys/ - possible bugs



Hi,

I compiled a list of all local variables in src/sys/ (r188000), which are only written to, but never read. This is more than the GCC warning, which only complains about variables, which are only declared (and maybe initialised) and not used otherwise. In contrast this list contains variables with the following usage pattern:

int w = 42; // GCC warns about this ...
int x; // ... but not this
x = 23;
x++;
return 0;

The list contains about 700 entries. About three dozen concern variables named 'error'. Here's one *example* from the list:

sys/dev/kbdmux/kbdmux.c:1304

In the function kbdmux_modevent() the variable 'error' is assigned values eight times, but at the end of the function there is just a return 0; and the variable is never read. Probably the value should be returned.

You can find the list here:
http://tron.homeunix.org/unread_variables.log

The list was generated by cparser, a C99 compiler, which uses libFIRM for optimisation and code generation (lang/cparser in the ports).


A small disclaimer: There might be some false positives due to errors
which are caused by HEAD sources in combination with my installed 7.x
headers plus a hacked up build process. Also some warnings are the result from variables, which are only used in debug macros, so td = curthread; KASSERT(td != NULL); provokes a warning (I consider this bad style). Nonetheless the number of false positives should be low. If there is interest, then I can compile a "proper" list.
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Why INFINITE loop in a thread occupy so much CPU time??
    ... With the attendant warning about the constant expression. ... This is a common programming technique. ... Good programming practice would consist of using the compiler at ... One can write 'bool' in C++ but not C. ...
    (microsoft.public.vc.mfc)
  • write-only variables in src/sys/ - possible bugs
    ... This is more than the GCC warning, which only complains about variables, which are only declared and not used otherwise. ... The list was generated by cparser, a C99 compiler, which uses libFIRM for optimisation and code generation. ... Nonetheless the number of false positives should be low. ...
    (freebsd-current)
  • Re: help needed please!
    ... But some compilers like to give you a warning ... Each warning a compiler can give you is important when you not ... but you may use flages to handle flags to handle flags when you ... >> stdout is line bufferd and until one or both of the following cases is ...
    (comp.lang.c)
  • Re: Overloading abstract methods
    ... I'm calling this abstract class ResumeWriter. ... > use of in each subclass is up to you. ... >> However, if I do that, I get compiler warnings that the parameters for ... Disable that warning. ...
    (comp.lang.java.programmer)
  • Re: Portability / compatibility issues
    ... I have posted my test code below, and the results I get on each compiler. ... The crux of the matter is that the 'strstr' function differs wildly in its behaviour on different platforms, and precious few man pages will actually provide a worked example of any function, let alone this one. ... I have had to write the "has_slash" function and use the reserved work SLASH already, to get around the problems that strstrgives me. ...
    (comp.lang.c)