Advent4 patch, second try

Luis Javier Merino ljmerino at gmail.com
Wed Sep 26 17:22:50 CEST 2007


 		exit(0);
-	if (sptr = strchr(username, '\n'))
+	if (sptr == strchr(username, '\n'))
 		*sptr = '\0';

It is customary to assign values to a variable inside an if condition
if you intend to reuse the result of a function. When gcc issues a
warning asking if you instead intended to do a comparison, the way to
silence the warning is to tell the compiler you really intended to do
an assignment by placing the assignment inside parentheses:

 		exit(0);
-	if (sptr = strchr(username, '\n'))
+	if ((sptr = strchr(username, '\n')))
 		*sptr = '\0';


Aside from that, I wouldn't really lose time fixing warnings on  code
written for pre-ANSI compilers.

Regards,



More information about the dslinux-devel mailing list