From: paul k. <pau...@xs...> - 2005-06-06 07:08:52
|
Hi Michael, Here is the warning I get from the plugin_mysql.c file. gcc -DHAVE_CONFIG_H -I. -I. -I. -D_GNU_SOURCE -Wall -W -g -O2 -c plugin_mysql.c plugin_mysql.c: In function `my_MySQLstatus': plugin_mysql.c:195: warning: ordered comparison of pointer with integer zero plugin_mysql.c:198: warning: assignment discards qualifiers from pointer target type First one is a true bug. This if (configure_mysql > 0) { should be if (configure_mysql() > 0) { For the second warning. In my mysql/mysql.h is mysql_stat defined as const char * STDCALL mysql_stat(MYSQL *mysql); So need to use some const qualifiers: Here is the modified function. I can't commit the changes because of some "sticky flag" :-( static void my_MySQLstatus(RESULT * result) { *const *char *value = ""; *const *char *status; if (*configure_mysql() *> 0) { mysql_ping(&conex); status = mysql_stat(&conex); if (!status) { error("[MySQL] status error: %s", mysql_error(&conex)); value = "error"; } else { value = status; } } SetResult(&result, R_STRING, value); } Cheers, Paul |
From: paul k. <pau...@xs...> - 2005-06-06 07:23:45
|
Here is the cvs diff output to make the changes more clear: (Sorry I don't know how to create a diff file directly from cvs) Index: plugin_mysql.c =================================================================== RCS file: /cvsroot/lcd4linux/lcd4linux/plugin_mysql.c,v retrieving revision 1.6 diff -r1.6 plugin_mysql.c 192,193c192,193 < char *value = ""; < char *status; --- > const char *value = ""; > const char *status; 195c195 < if (configure_mysql > 0) { --- > if (configure_mysql() > 0) { paul kamphuis wrote: > Hi Michael, > > Here is the warning I get from the plugin_mysql.c file. > > gcc -DHAVE_CONFIG_H -I. -I. -I. -D_GNU_SOURCE -Wall -W -g -O2 -c > plugin_mysql.c > plugin_mysql.c: In function `my_MySQLstatus': > plugin_mysql.c:195: warning: ordered comparison of pointer with > integer zero > plugin_mysql.c:198: warning: assignment discards qualifiers from > pointer target type > > First one is a true bug. > This > if (configure_mysql > 0) { > should be > if (configure_mysql() > 0) { > > > For the second warning. > In my mysql/mysql.h is mysql_stat defined as > const char * STDCALL mysql_stat(MYSQL *mysql); > So need to use some const qualifiers: > > Here is the modified function. I can't commit the changes because of > some "sticky flag" :-( > > static void my_MySQLstatus(RESULT * result) > { > *const *char *value = ""; > *const *char *status; > > if (*configure_mysql() *> 0) { > > mysql_ping(&conex); > status = mysql_stat(&conex); > if (!status) { > error("[MySQL] status error: %s", mysql_error(&conex)); > value = "error"; > } else { > value = status; > } > } > > SetResult(&result, R_STRING, value); > } > > Cheers, > > Paul > > > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far can you > shotput > a projector? How fast can you ride your desk chair down the office > luge track? > If you want to score the big prize, get to know the little guy. Play > to win an NEC 61" plasma display: http://www.necitguy.com/?r=20 > _______________________________________________ > Lcd4linux-devel mailing list > Lcd...@li... > https://lists.sourceforge.net/lists/listinfo/lcd4linux-devel > > |
From: Michael R. <re...@eu...> - 2005-06-06 08:36:14
|
Hi Paul, > Here is the cvs diff output to make the changes more clear: > (Sorry I don't know how to create a diff file directly from cvs) cvs -z9 diff -bu >file.diff > 192,193c192,193 > < char *value = ""; > < char *status; > --- >> const char *value = ""; >> const char *status; Hmmm... I don't think this is correct... Could you please send me your mysql.h? > 195c195 > < if (configure_mysql > 0) { > --- >> if (configure_mysql() > 0) { This is really a bug... bye, Michael -- Michael Reinelt <re...@eu...> http://home.pages.at/reinelt GPG-Key 0xDF13BA50 ICQ #288386781 |
From: paul k. <pau...@xs...> - 2005-06-06 09:01:30
|
Hi Michael, >>< char *value = ""; >>< char *status; >>--- >> >> >>> const char *value = ""; >>> const char *status; >>> >>> > >Hmmm... I don't think this is correct... >Could you please send me your mysql.h? > > > Why shouldn't this be correct? Even if mysql_stat returns a char * (which in my case it doesn't), the string are never modified in the function. So there is no reason why these can't be defined as const. cheers, Paul |
From: Michael R. <re...@eu...> - 2005-06-06 09:24:53
|
Hi Paul, >>> - char *value = ""; >>> - char *status; >>> + const char *value = ""; >>> + const char *status; > Why shouldn't this be correct? Even if mysql_stat returns a char * > (which in my case it doesn't), the string are never modified in the > function. > So there is no reason why these can't be defined as const. You are right. 'const' confuses me sometimes :-) I did check in your changes. bye, Michael -- Michael Reinelt <re...@eu...> http://home.pages.at/reinelt GPG-Key 0xDF13BA50 ICQ #288386781 |