Skip to content

Commit 3254310

Browse files
Ramsay Jonesgitster
Ramsay Jones
authored andcommitted
obstack.c: Fix some sparse warnings
In particular, sparse issues the following warnings: compat/obstack.c:176:17: warning: Using plain integer as NULL pointer compat/obstack.c:224:17: warning: Using plain integer as NULL pointer compat/obstack.c:324:16: warning: Using plain integer as NULL pointer compat/obstack.c:329:16: warning: Using plain integer as NULL pointer compat/obstack.c:347:16: warning: Using plain integer as NULL pointer compat/obstack.c:362:19: warning: Using plain integer as NULL pointer compat/obstack.c:379:29: warning: Using plain integer as NULL pointer compat/obstack.c:399:1: error: symbol 'print_and_abort' redeclared with \ different type (originally declared at compat/obstack.c:95) \ - different modifiers Signed-off-by: Ramsay Jones <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a946ef5 commit 3254310

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

compat/obstack.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ _obstack_begin (struct obstack *h,
173173
alignment - 1);
174174
h->chunk_limit = chunk->limit
175175
= (char *) chunk + h->chunk_size;
176-
chunk->prev = 0;
176+
chunk->prev = NULL;
177177
/* The initial chunk now contains no empty object. */
178178
h->maybe_empty_object = 0;
179179
h->alloc_failed = 0;
@@ -221,7 +221,7 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
221221
alignment - 1);
222222
h->chunk_limit = chunk->limit
223223
= (char *) chunk + h->chunk_size;
224-
chunk->prev = 0;
224+
chunk->prev = NULL;
225225
/* The initial chunk now contains no empty object. */
226226
h->maybe_empty_object = 0;
227227
h->alloc_failed = 0;
@@ -321,12 +321,12 @@ _obstack_allocated_p (struct obstack *h, void *obj)
321321
/* We use >= rather than > since the object cannot be exactly at
322322
the beginning of the chunk but might be an empty object exactly
323323
at the end of an adjacent chunk. */
324-
while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
324+
while (lp != NULL && ((void *) lp >= obj || (void *) (lp)->limit < obj))
325325
{
326326
plp = lp->prev;
327327
lp = plp;
328328
}
329-
return lp != 0;
329+
return lp != NULL;
330330
}
331331

332332
/* Free objects in obstack H, including OBJ and everything allocate
@@ -344,7 +344,7 @@ obstack_free (struct obstack *h, void *obj)
344344
/* We use >= because there cannot be an object at the beginning of a chunk.
345345
But there can be an empty object at that address
346346
at the end of another chunk. */
347-
while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
347+
while (lp != NULL && ((void *) lp >= obj || (void *) (lp)->limit < obj))
348348
{
349349
plp = lp->prev;
350350
CALL_FREEFUN (h, lp);
@@ -359,7 +359,7 @@ obstack_free (struct obstack *h, void *obj)
359359
h->chunk_limit = lp->limit;
360360
h->chunk = lp;
361361
}
362-
else if (obj != 0)
362+
else if (obj != NULL)
363363
/* obj is not in any of the chunks! */
364364
abort ();
365365
}
@@ -376,7 +376,7 @@ _obstack_memory_used (struct obstack *h)
376376
register struct _obstack_chunk* lp;
377377
register int nbytes = 0;
378378

379-
for (lp = h->chunk; lp != 0; lp = lp->prev)
379+
for (lp = h->chunk; lp != NULL; lp = lp->prev)
380380
{
381381
nbytes += lp->limit - (char *) lp;
382382
}
@@ -395,7 +395,6 @@ _obstack_memory_used (struct obstack *h)
395395
# endif
396396

397397
static void
398-
__attribute__ ((noreturn))
399398
print_and_abort (void)
400399
{
401400
/* Don't change any of these strings. Yes, it would be possible to add

0 commit comments

Comments
 (0)