Date: Fri, 31 Jul 2015 11:13:16 -0500 From: Pedro Giffuni <pfg@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r286102 - head/usr.bin/wall Message-ID: <55BB9E9C.9030608@FreeBSD.org> In-Reply-To: <20150731162408.M1843@besplex.bde.org> References: <201507310112.t6V1CWh8034232@repo.freebsd.org> <20150731162408.M1843@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 07/31/15 02:12, Bruce Evans wrote: > On Fri, 31 Jul 2015, Pedro F. Giffuni wrote: > ... > >> static char errbuf[1024]; > > Another static buffer. The function is obviously not reentrant. This > large static buffer mainly wastes space all the time instead of only > when the function is called. > But if I drop that static I get a bunch of errors: /usr/src/usr.bin/wall/ttymsg.c:82:11: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ /usr/src/usr.bin/wall/ttymsg.c:94:11: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ /usr/src/usr.bin/wall/ttymsg.c:134:13: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ /usr/src/usr.bin/wall/ttymsg.c:160:11: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ ... >> char *p; >> int forked; >> @@ -71,8 +71,8 @@ ttymsg(struct iovec *iov, int iovcnt, co >> if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0]))) >> return ("too many iov's (change code in wall/ttymsg.c)"); >> >> + strlcat(device, line, sizeof(device)); > > This depends on the slow reinitialization on every entry. The combined > initialization (initializer + strlcat) is an obfuscated way of > concatenating 2 strings. The clearest way is snprintf with %s%s format. > I will do that, thanks. Pedro.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55BB9E9C.9030608>