On Thu, 15 Dec 2016, Eduard Rozenberg wrote:

> In case it?s useful, here are several warnings that were generated
> on my Linux compile on Slackware 14.1 kernel 3.10.17.
>
> ...
>
> gcc -DHAVE_CONFIG_H -I. -I../..  -I../../smtpd -I../../openbsd-compat -I. 
> -I/usr/include  -DSMTPD_CONFDIR=\"/etc/opensmtpd\" 
> -DPATH_CHROOT=\"/var/empty\" -DPATH_SMTPCTL=\"/usr/sbin/smtpctl\" 
> -DPATH_MAILLOCAL=\"/usr/libexec/opensmtpd/mail.local\" 
> -DPATH_LIBEXEC=\"/usr/libexec/opensmtpd\" -DHAVE_CONFIG_H -DIO_SSL 
> -DCA_FILE=\"/etc/ssl/certs/ca-certificates.crt\" -O2 -fPIC -fstack-protector  
> -fPIC -DPIC -Wall -Wpointer-arith -Wuninitialized -Wsign-compare 
> -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign 
> -Wno-unused-result -fno-strict-aliasing -fno-builtin-memset -D_BSD_SOURCE  
> -D_GNU_SOURCE -DNEED_EVENT_ASR_RUN -c -o ../../smtpd/smtpd-to.o `test -f 
> '../../smtpd/to.c' || echo './'`../../smtpd/to.c
> ../../smtpd/to.c: In function 'time_to_text':
> ../../smtpd/to.c:212:5: warning: assignment discards 'const' qualifier from 
> pointer target type [enabled by default]
>   tz = lt->tm_zone;
>      ^
>
> gcc -DHAVE_CONFIG_H -I. -I../..  -I../../smtpd -I../../openbsd-compat -I. 
> -I/usr/include  -DSMTPD_CONFDIR=\"/etc/opensmtpd\" 
> -DPATH_CHROOT=\"/var/empty\" -DPATH_SMTPCTL=\"/usr/sbin/smtpctl\" 
> -DPATH_MAILLOCAL=\"/usr/libexec/opensmtpd/mail.local\" 
> -DPATH_LIBEXEC=\"/usr/libexec/opensmtpd\" -DHAVE_CONFIG_H -DNO_IO 
> -DPATH_GZCAT=\"/usr/bin/zcat\" 
> -DPATH_ENCRYPT=\"/usr/libexec/opensmtpd/encrypt\" -O2 -fPIC -fstack-protector 
>  -fPIC -DPIC -Wall -Wpointer-arith -Wuninitialized -Wsign-compare 
> -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign 
> -Wno-unused-result -fno-strict-aliasing -fno-builtin-memset -D_BSD_SOURCE  
> -D_GNU_SOURCE -c -o ../../smtpd/smtpctl-parser.o `test -f 
> '../../smtpd/parser.c' || echo './'`../../smtpd/parser.c
> ../../smtpd/parser.c:123:1: warning: 'cmd_dump' defined but not used 
> [-Wunused-function]
>  cmd_dump(struct node *node, int depth)
>  ^
>

For smtpd/to.c the tz variable can be declared 'const'.

And it is good form to initialize all variable declarations.

Here is a patch:

--- smtpd/to.c.orig     2016-10-12 00:16:24.000000000 -0700
+++ smtpd/to.c  2016-12-16 12:48:49.471707606 -0800
@@ -195,13 +195,13 @@
 const char *
 time_to_text(time_t when)
 {
-       struct tm *lt;
-       static char buf[40];
+       struct tm *lt = NULL;
+       static char buf[40] = "";
        char *day[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
        char *month[] = {"Jan","Feb","Mar","Apr","May","Jun",
                         "Jul","Aug","Sep","Oct","Nov","Dec"};
-       char *tz;
-       long offset;
+       const char *tz = NULL;
+       long offset = 0;

        lt = localtime(&when);
        if (lt == NULL || when == 0)

-----------------------------
-Richard Narron

-- 
You received this mail because you are subscribed to [email protected]
To unsubscribe, send a mail to: [email protected]

Reply via email to