On Mon, Oct 19, 2015 at 10:05:09AM +0200, Edward Bartolo wrote:
> Hi,
> 
> Could someone explain to me what is the meaning of this error and what
> I should do to avoid having this warning?
> 
> edbarx@edbarx-pc:~/netman/backend_src/src$ gcc -Wall -Wfatal-errors -g
> -lm -I../include core_functions.c file_functions.c backend.c
> essid_encoder.c automated_scanner.c -o backend
> automated_scanner.c: In function ‘autoWirelessScanPlus_RN’:
> automated_scanner.c:521:2: warning: suggest parentheses around
> assignment used as truth value [-Wparentheses]
>   if ( dir = opendir(IFACES_PATH) ) {
>   ^

My guess is thet it's suggesting the coding convention of adding extra 
(unnecessary) parentheses to emphasize that you really do want an 
assignment here instead of an equality test.  migrants from other 
programming languages often use '=' as an equality text and are 
repeatedly annoyed that C interprets it as an assignment.  Just a 
migrants from C are repeatedly annoyed by the reverse.

I don't know why extra parentheses should apparently be taken to mean "I 
really want this to be an assignment".  I would commonly put parentheses 
around equality tests when there are and's and or's around, and if I 
miscoded them as '=' I wouldn't want them silently interpreted as 
assignments.

-- hendrik
_______________________________________________
Dng mailing list
[email protected]
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to