zsh-workers
 help / color / mirror / code / Atom feed
* Re: 0 vs. NULL (RE: Worrisome warnings after recent patches)
@ 1999-03-04 10:42 Sven Wischnowsky
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 1999-03-04 10:42 UTC (permalink / raw)
  To: zsh-workers


Bruce Stephens wrote:

> Bernd Eggink <eggink@uni-hamburg.de> writes:
> 
> > Andrej Borsenkow wrote:
> 
> > > What is the point of using NULL to initialize null pointer. The only
> > > portable and official way is to use `0'(zero), that is garanteed to be
> > > converted to whatever representation null pointer has on a given system.
> > 
> > No, this applies to C++ only, not to C. In C you should use the NULL
> > macro or (void*)0.
> 
> There's an issue with arguments to functions which don't have
> prototypes, but apart from that, the literal 0 as a pointer should be
> fine in C.

Since the original message was a reaction to my patch: I know that `0' 
should be fine in C (at least with modern compilers) and personally I
prefer it. But using `NULL' is the convention used throughout the zsh
code, so...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: Worrisome warnings after recent patches
@ 1999-03-04  7:50 Sven Wischnowsky
  1999-03-04  8:31 ` 0 vs. NULL (RE: Worrisome warnings after recent patches) Andrej Borsenkow
  0 siblings, 1 reply; 4+ messages in thread
From: Sven Wischnowsky @ 1999-03-04  7:50 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote (in a mail directly to me):

> ../../../zsh-3.1.5/Src/Zle/zle_tricky.c: In function `join_strs':
> ../../../zsh-3.1.5/Src/Zle/zle_tricky.c:1803: warning: `mp' might be used uninitialized in this function
> ../../../zsh-3.1.5/Src/Zle/zle_tricky.c: In function `join_ends':
> ../../../zsh-3.1.5/Src/Zle/zle_tricky.c:1930: warning: `tn' might be used uninitialized in this function
>
> ... [ more of these warnings ]

The first one really was wrong, but in the other cases the variables
could not have been used uninitialized, partly due to the calling
context but in most cases due to the tests in the functions
themselves.

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Wed Mar  3 17:22:42 1999
+++ Src/Zle/zle_tricky.c	Thu Mar  4 08:44:58 1999
@@ -1873,7 +1873,7 @@
 	    if (!t)
 		break;
 	} else {
-	    if (rr <= mp->llen) {
+	    if (rr <= 1) {
 		char *or = rs;
 
 		rs = realloc(rs, (rl += 20));
@@ -1927,7 +1927,7 @@
 	} else {
 	    /* Different anchors, see if we can find matching anchors
 	     * further down the lists. */
-	    Cline to, tn;
+	    Cline to, tn = NULL;
 	    int t = 0;
 
 	    /* But first build the common prefix. */
@@ -3414,6 +3414,7 @@
 	}
     }
     while (ll && lw) {
+	t = 0;
 	/* First try the matchers. */
 	for (ms = mstack; ms; ms = ms->next) {
 	    for (mp = ms->matcher; mp; mp = mp->next) {
@@ -3655,6 +3656,7 @@
 	}
     }
     while (ll && lw) {
+	t = 0;
 	for (ms = mstack; ms; ms = ms->next) {
 	    for (mp = ms->matcher; mp; mp = mp->next) {
 		if (lm == mp)
@@ -3984,11 +3986,12 @@
 	   char *suf, char *group, char *rems, char *remf, char *ign,
 	   int flags, int aflags, Cmatcher match, char *exp, char **argv)
 {
-    char *s, *t, *e, *me, *ms, *lipre = NULL, *lpre, *lsuf, **aign = NULL;
-    int lpl, lsl, i, pl, sl, test, bpl, bsl, llpl, llsl;
-    Aminfo ai;
+    char *s, *t, *e, *me, *ms, *lipre = NULL, *lpre = NULL, *lsuf = NULL;
+    char **aign = NULL;
+    int lpl, lsl, i, pl, sl, test, bpl, bsl, llpl = 0, llsl = 0;
+    Aminfo ai = NULL;
     Cline lc = NULL;
-    LinkList l;
+    LinkList l = NULL;
     Cmatch cm;
     struct cmlist mst;
     Cmlist oms = mstack;
@@ -4132,7 +4135,7 @@
 	    }
 	    /* Walk through the matches given. */
 	    for (; (s = dupstring(*argv)); argv++) {
-		sl = strlen(s);
+		sl = pl = strlen(s);
 		lc = NULL;
 		ms = NULL;
 		bpl = brpl;
@@ -5742,7 +5745,7 @@
     Compcond or, cc;
     Comp comp;
     int compadd, m = 0, d = 0, t, tt, i, j, a, b;
-    char *sc, *s, *ss;
+    char *sc = NULL, *s, *ss;
 
     /* This loops over the patterns separated by `-'s. */
     for (compc = occ->ext; compc; compc = compc->next) {
@@ -7871,7 +7874,7 @@
 	    }
 	}
 	else if (g->lcount) {
-	    int n = g->lcount, nl = (n + ncols - 1) / ncols, nc = nl, i, j, a;
+	    int n = g->lcount, nl = (n + ncols - 1) / ncols, nc = nl, i, j, a = 0;
 	    Cmatch *q;
 
 	    if (n && pnl) {

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

end of thread, other threads:[~1999-03-04 10:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-04 10:42 0 vs. NULL (RE: Worrisome warnings after recent patches) Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-03-04  7:50 Worrisome warnings after recent patches Sven Wischnowsky
1999-03-04  8:31 ` 0 vs. NULL (RE: Worrisome warnings after recent patches) Andrej Borsenkow
1999-03-04  8:42   ` Bernd Eggink
1999-03-04 10:35     ` Bruce Stephens

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).