Skip to content

Commit

Permalink
obstack.c: Fix some sparse warnings
Browse files Browse the repository at this point in the history
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 <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ramsay Jones authored and gitster committed Sep 11, 2011
1 parent a946ef5 commit 3254310
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions compat/obstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ _obstack_begin (struct obstack *h,
alignment - 1);
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
chunk->prev = NULL;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
h->alloc_failed = 0;
Expand Down Expand Up @@ -221,7 +221,7 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
alignment - 1);
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
chunk->prev = NULL;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
h->alloc_failed = 0;
Expand Down Expand Up @@ -321,12 +321,12 @@ _obstack_allocated_p (struct obstack *h, void *obj)
/* We use >= rather than > since the object cannot be exactly at
the beginning of the chunk but might be an empty object exactly
at the end of an adjacent chunk. */
while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
while (lp != NULL && ((void *) lp >= obj || (void *) (lp)->limit < obj))
{
plp = lp->prev;
lp = plp;
}
return lp != 0;
return lp != NULL;
}

/* Free objects in obstack H, including OBJ and everything allocate
Expand All @@ -344,7 +344,7 @@ obstack_free (struct obstack *h, void *obj)
/* We use >= because there cannot be an object at the beginning of a chunk.
But there can be an empty object at that address
at the end of another chunk. */
while (lp != 0 && ((void *) lp >= obj || (void *) (lp)->limit < obj))
while (lp != NULL && ((void *) lp >= obj || (void *) (lp)->limit < obj))
{
plp = lp->prev;
CALL_FREEFUN (h, lp);
Expand All @@ -359,7 +359,7 @@ obstack_free (struct obstack *h, void *obj)
h->chunk_limit = lp->limit;
h->chunk = lp;
}
else if (obj != 0)
else if (obj != NULL)
/* obj is not in any of the chunks! */
abort ();
}
Expand All @@ -376,7 +376,7 @@ _obstack_memory_used (struct obstack *h)
register struct _obstack_chunk* lp;
register int nbytes = 0;

for (lp = h->chunk; lp != 0; lp = lp->prev)
for (lp = h->chunk; lp != NULL; lp = lp->prev)
{
nbytes += lp->limit - (char *) lp;
}
Expand All @@ -395,7 +395,6 @@ _obstack_memory_used (struct obstack *h)
# endif

static void
__attribute__ ((noreturn))
print_and_abort (void)
{
/* Don't change any of these strings. Yes, it would be possible to add
Expand Down

0 comments on commit 3254310

Please sign in to comment.