zsh-workers
 help / color / mirror / code / Atom feed
* Used-uninitalized error I hadn't seen before
@ 2018-09-07 19:44 Bart Schaefer
  2018-09-07 23:22 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2018-09-07 19:44 UTC (permalink / raw)
  To: Zsh hackers list

Just built zsh 5.6 on a new host.

computil.c: In function 'ca_inactive':
computil.c:1832: warning: 'grplen' may be used uninitialized in this function

It's not immediately clear to me to what grplen should be initialized.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Used-uninitalized error I hadn't seen before
  2018-09-07 19:44 Used-uninitalized error I hadn't seen before Bart Schaefer
@ 2018-09-07 23:22 ` Oliver Kiddle
  2018-09-07 23:51   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2018-09-07 23:22 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

Bart wrote:
> Just built zsh 5.6 on a new host.

What compiler is this and what options? I don't get the warning with any
compiler I've got. It'd be useful to track down which uses of the
variable cause the warning.

> computil.c: In function 'ca_inactive':
> computil.c:1832: warning: 'grplen' may be used uninitialized in this function
>
> It's not immediately clear to me to what grplen should be initialized.

I'm fairly sure that it is wrong and grplen can't be used uninitialized.
The trouble with adding an initialisation to silence the warning is that
it wouldn't be a meaningful value. That can make the code harder to follow
later because someone reading the code might puzzle over that initial
value.

Oliver

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Used-uninitalized error I hadn't seen before
  2018-09-07 23:22 ` Oliver Kiddle
@ 2018-09-07 23:51   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2018-09-07 23:51 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: Zsh hackers list

On Fri, Sep 7, 2018 at 4:22 PM, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
>
> What compiler is this and what options? I don't get the warning with any
> compiler I've got. It'd be useful to track down which uses of the
> variable cause the warning.

This is on what I have to assume (I'm not the admin) is a stock CentOS 6.9 host:

gcc -c -I. -I../../Src -I../../Src -I../../Src/Zle -I.
-DHAVE_CONFIG_H -DMODULE -Wall -Wmissing-prototypes -O2 -fPIC -o
computil..o computil.c

gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)

> I'm fairly sure that it is wrong and grplen can't be used uninitialized.

So we have this:

   1847             if (sep > x) { /* exclusion included a set or group name */
   1848                 grp = x;
   1849                 grplen = sep - grp;
   1850                 x = sep;
   1851             }

and then later uses of grplen are protected by expressions like

   1853             if (excludeall || (x[0] == ':' && !x[1])) {
   1854                 if (grp) {

e.g., at line 1858 grplen is passed to strncmp() and at line 1859 is
used in a subscript.  It's not obvious to me why the conditions on
1853-1854 are a superset of 1847.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-07 23:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07 19:44 Used-uninitalized error I hadn't seen before Bart Schaefer
2018-09-07 23:22 ` Oliver Kiddle
2018-09-07 23:51   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).