From d39c092fb41911a31951a7072cdf4bbd5a13d9ef Mon Sep 17 00:00:00 2001 From: marschap Date: Fri, 14 Apr 2006 08:04:09 +0000 Subject: [PATCH] fix a few more warnings --- acinclude.m4 | 146 ++++++++++++++++++++++++ clients/lcdproc/chrono.c | 17 +-- configure.in | 7 +- docs/lcdproc-user/how-to-obtain.docbook | 106 ++--------------- server/drivers/bayrad.c | 4 +- server/drivers/pylcd.c | 4 +- server/input.c | 13 ++- 7 files changed, 179 insertions(+), 118 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index aa359ef..7c7e9e7 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -735,3 +735,149 @@ AC_SUBST(enable_dot) AC_SUBST(enable_html_dox) AC_SUBST(enable_latex_dox) ]) + +dnl From: http://autoconf-archive.cryp.to/ax_cflags_gcc_option.html +dnl Author: Guido Draheim +dnl Last Modified: 2003-11-04 +AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl +AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl +AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl +AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], +VAR,[VAR="no, unknown" + AC_LANG_SAVE + AC_LANG_C + ac_save_[]FLAGS="$[]FLAGS" +for ac_arg dnl +in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC + # +do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + AC_TRY_COMPILE([],[return 0;], + [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) +done + FLAGS="$ac_save_[]FLAGS" + AC_LANG_RESTORE +]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_ifvaln($4,$4) ;; + *) m4_ifvaln($3,$3,[ + if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null + then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) + else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) + m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" + fi ]) ;; +esac +AS_VAR_POPDEF([VAR])dnl +AS_VAR_POPDEF([FLAGS])dnl +]) + + +dnl the only difference - the LANG selection... and the default FLAGS + +AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl +AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl +AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl +AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], +VAR,[VAR="no, unknown" + AC_LANG_SAVE + AC_LANG_CXX + ac_save_[]FLAGS="$[]FLAGS" +for ac_arg dnl +in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC + # +do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + AC_TRY_COMPILE([],[return 0;], + [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) +done + FLAGS="$ac_save_[]FLAGS" + AC_LANG_RESTORE +]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_ifvaln($4,$4) ;; + *) m4_ifvaln($3,$3,[ + if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null + then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) + else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) + m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" + fi ]) ;; +esac +AS_VAR_POPDEF([VAR])dnl +AS_VAR_POPDEF([FLAGS])dnl +]) + +dnl ------------------------------------------------------------------------- + +AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl +AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl +AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl +AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], +VAR,[VAR="no, unknown" + AC_LANG_SAVE + AC_LANG_C + ac_save_[]FLAGS="$[]FLAGS" +for ac_arg dnl +in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC + # +do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + AC_TRY_COMPILE([],[return 0;], + [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) +done + FLAGS="$ac_save_[]FLAGS" + AC_LANG_RESTORE +]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_ifvaln($4,$4) ;; + *) m4_ifvaln($3,$3,[ + if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null + then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) + else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) + m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" + fi ]) ;; +esac +AS_VAR_POPDEF([VAR])dnl +AS_VAR_POPDEF([FLAGS])dnl +]) + + +dnl the only difference - the LANG selection... and the default FLAGS + +AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl +AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl +AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl +AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], +VAR,[VAR="no, unknown" + AC_LANG_SAVE + AC_LANG_CXX + ac_save_[]FLAGS="$[]FLAGS" +for ac_arg dnl +in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC + # +do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` + AC_TRY_COMPILE([],[return 0;], + [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) +done + FLAGS="$ac_save_[]FLAGS" + AC_LANG_RESTORE +]) +case ".$VAR" in + .ok|.ok,*) m4_ifvaln($3,$3) ;; + .|.no|.no,*) m4_ifvaln($4,$4) ;; + *) m4_ifvaln($3,$3,[ + if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null + then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) + else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) + m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" + fi ]) ;; +esac +AS_VAR_POPDEF([VAR])dnl +AS_VAR_POPDEF([FLAGS])dnl +]) + +AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, +[AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])]) + +AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, +[AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])]) + diff --git a/clients/lcdproc/chrono.c b/clients/lcdproc/chrono.c index 5fceba3..b8e11fc 100644 --- a/clients/lcdproc/chrono.c +++ b/clients/lcdproc/chrono.c @@ -99,7 +99,6 @@ int time_screen (int rep, int display, int *flags_ptr) { char now[20]; - char day[16], month[16]; int xoffs; int days, hour, min, sec; static int heartbeat = 0; @@ -147,8 +146,8 @@ time_screen (int rep, int display, int *flags_ptr) } if (lcd_hgt >= 4) { - strcpy (day, shortdays[rtime->tm_wday]); - strcpy (month, shortmonths[rtime->tm_mon]); + char *day = shortdays[rtime->tm_wday]; + char *month = shortdays[rtime->tm_wday]; machine_get_uptime(&uptime, &idle); @@ -458,9 +457,13 @@ big_clock_screen (int rep, int display, int *flags_ptr) int mini_clock_screen (int rep, int display, int *flags_ptr) { + time_t thetime; struct tm *rtime; - struct timeval ttime; static char colon[] = {':', ' '}; + static int heartbeat = 0; + + // toggle colon display + heartbeat ^= 1; if ((*flags_ptr & INITIALIZED) == 0) { *flags_ptr |= INITIALIZED; @@ -470,10 +473,10 @@ mini_clock_screen (int rep, int display, int *flags_ptr) sock_send_string (sock, "widget_add N one string\n"); } - gettimeofday(&ttime, NULL); - rtime = localtime (&ttime.tv_sec); + time (&thetime); + rtime = localtime (&thetime); - sprintf(tmp, "%02d%c%02d", rtime->tm_hour, colon[(ttime.tv_usec / 500000) & 1], rtime->tm_min); + sprintf(tmp, "%02d%c%02d", rtime->tm_hour, colon[heartbeat & 0x01], rtime->tm_min); sprintf(buffer, "widget_set N one %d %d {%s}\n", ((lcd_wid - 5) / 2) + 1, (lcd_hgt / 2), tmp); sock_send_string (sock, buffer); diff --git a/configure.in b/configure.in index d806959..c1e4a3c 100644 --- a/configure.in +++ b/configure.in @@ -75,11 +75,8 @@ AC_PROG_RANLIB dnl Avoid unused static function warnings CFLAGS="-Wall $CFLAGS" -if test "x$GCC" = "xyes"; then - # this may produce a harmless warning with older GCC's: - # unrecognized option '-Wno-unused-function' - CFLAGS="$CFLAGS -Wno-unused-function" -fi +AX_CFLAGS_GCC_OPTION(-Wno-unused-function) +AX_CFLAGS_GCC_OPTION(-ftrampolines) export CFLAGS dnl Solaris diff --git a/docs/lcdproc-user/how-to-obtain.docbook b/docs/lcdproc-user/how-to-obtain.docbook index 6373c44..da33191 100644 --- a/docs/lcdproc-user/how-to-obtain.docbook +++ b/docs/lcdproc-user/how-to-obtain.docbook @@ -5,107 +5,33 @@ Versioning -At the time of writing there were four versions of LCDproc floating around on the +At the time of writing there were two majors versions of LCDproc floating around on the Internet. -LCDproc 0.4.1 +LCDproc 0.4.3 to 0.4.5 -LCDproc 0.4.1 was the last "stable" release of LCDproc. It still uses the old -command line configuration. - - - -There are known security problems with LCDproc 0.4.1. A remote exploit is possible. -An attacker can make use of some buffer-overflows in the client communication -code of LCDd, in order to get root access to your system. -Therefore running LCDproc 0.4.1 is NOT RECOMMENDED! - - - - - - -LCDproc 0.4.2 - - -LCDproc 0.4.2 was meant to be the next stable release of LCDproc. As 0.4.1 -it uses the old command line configuration. - - - -The known issues about 0.4.1 had been fixed. Unfortunately the guy who had the last pending -patches on his box kind of "vanished" from the LCDproc mailing list. -Of course you can get 0.4.2 from CVS. BUT its current state is unknown. - - - - - - -LCDproc 0.4.3 - - -LCDproc 0.4.3 is the current stable release of LCDproc. It no longer uses the old +LCDproc 0.4.5 was the last stable release of LCDproc. It no longer uses the old command line configuration, but introduces the configuration file /etc/LCDd.conf. As well the driver API has slightly changed, which should not make older drivers incompatible, but might cause some trouble. As well the way LCDd reports messages (including error messages) has changed. - -Even though LCDproc 0.4.3 is the most stable version we can offer, it is still not perfect. - -LCDproc 0.4.4 +LCDproc 0.5.0 -LCDproc 0.4.4 will be the next stable release of LCDproc. +LCDproc 0.5.0 is the current stable version of LCDproc. It's recommended that you use this version. - - -The 0.4.x branch will only be slightly updated. E.g. we plan better support -of lcdproc (the client) for *BSD. Yet, the active development will move to -0.5 now. - - -As 0.5 will not be stable in the near future, we may also work on porting drivers -from 0.4.1 to 0.4.4 on demand. We do not have all the hardware LCDd supports. So, we -only work on drivers that can be tested by YOU. - - -As well, the development and inclusion of new drivers is possible. - - - - - - - -LCDproc 0.5 - - -LCDproc 0.5 is the developement version of LCDproc. Everything is possible ;) Drivers can already be -loaded at runtime. We will also work on client supplied menus and other nifty stuff. - - - -From time to time LCDproc 0.5 might not even compile due to drastic changes. -You have been warned! - - -Furthermore older drivers will NOT work with LCDproc 0.5 AT ALL! -Feel free to port a driver that has not been ported to 0.5 yet ;) - - @@ -146,15 +72,6 @@ or Of course you can download the latest stuff from CVS via anonymous login. - -Create a "cvs" directory somewhere on your machine (not really neccessary but useful): - - - -$ mkdir ~/cvs -$ cd ~/cvs - - Login to CVS: @@ -172,16 +89,16 @@ Get the files from CVS: -$ cvs -d:pserver:anonymous@cvs.lcdproc.sourceforge.net:/cvsroot/lcdproc checkout -r stable-0-4-3 lcdproc +$ cvs -d:pserver:anonymous@cvs.lcdproc.sourceforge.net:/cvsroot/lcdproc checkout -r stable-0-5-x lcdproc Once you've done that and want to update the downloaded files to the latest stuff -you can use the "update" command of CVS (Make sure you have logged in to CVS first.): +you can use the "update" command of CVS (Make sure to be in the lcdproc directory.): -$ cvs -d:pserver:anonymous@cvs.lcdproc.sourceforge.net:/cvsroot/lcdproc update -r stable-0-4-3 lcdproc +$ cvs update -d @@ -189,13 +106,6 @@ Now that you have downloaded the files you can prepare them for compiling, but f you should (you don't have to) copy them to another place on your machine: - -$ mkdir ~/lcdproc-cvs -$ cp -f -R ~/cvs/lcdproc ~/lcdproc-cvs/`date +%Y%m%d` -$ cd ~/lcdproc-cvs/`date +%Y%m%d` - - - diff --git a/server/drivers/bayrad.c b/server/drivers/bayrad.c index 2fe47df..08effcc 100644 --- a/server/drivers/bayrad.c +++ b/server/drivers/bayrad.c @@ -645,7 +645,7 @@ bayrad_hbar(Driver * drvthis, int x, int y, int len, int promille, int options) MODULE_EXPORT int bayrad_icon(Driver * drvthis, int x, int y, int icon) { - //PrivateData *p = drvthis->private_data; + /*PrivateData *p = drvthis->private_data; static char icons[3][5*8] = { { 1,1,1,1,1, // Empty Heart @@ -675,7 +675,7 @@ bayrad_icon(Driver * drvthis, int x, int y, int icon) 0,0,0,0,0, 1,0,1,0,1, } - }; + };*/ switch (icon) { case ICON_BLOCK_FILLED: diff --git a/server/drivers/pylcd.c b/server/drivers/pylcd.c index 5bd155f..d9deffc 100644 --- a/server/drivers/pylcd.c +++ b/server/drivers/pylcd.c @@ -136,7 +136,7 @@ read_tele(PrivateData *p, char *buffer) && (zeichen==cc)) { buffer[len]=0x00; - debug(RPT_DEBUG, "%s: read %s", __FUNCTION__, buffer); + /*debug(RPT_DEBUG, "%s: read %s", __FUNCTION__, buffer)*/; return True; } else @@ -204,7 +204,7 @@ real_send_tele(PrivateData *p, char *buffer, int len) /* Take a little nap. This works as a pacemaker */ usleep(50); - debug(RPT_DEBUG, "%s: sent %s", __FUNCTION__, buffer); + /*debug(RPT_DEBUG, "%s: sent %s", __FUNCTION__, buffer);*/ return 0; } diff --git a/server/input.c b/server/input.c index cb567bd..e6cc4ee 100644 --- a/server/input.c +++ b/server/input.c @@ -128,14 +128,19 @@ handle_input () void input_send_to_client (Client * c, const char * key) { char * s; + size_t size = strlen(key) + sizeof("key %s\n"); // this is large enough debug (RPT_DEBUG, "%s( client=[%d], key=\"%.40s\" )", __FUNCTION__, c->sock, key); /* Allocate just as much as we need */ - s = malloc (strlen(key) + strlen("key \n") + 1); - sprintf(s, "key %s\n", key); - sock_send_string(c->sock, s); - free (s); + s = calloc (1, size); + if (s != NULL) { + snprintf(s, size, "key %s\n", key); + sock_send_string(c->sock, s); + free (s); + } + else + report(RPT_ERR, "%s: malloc failure", __FUNCTION__); }