Merge branch 'fk/use-kwset-pickaxe-grep-f'

* fk/use-kwset-pickaxe-grep-f:
  obstack.c: Fix some sparse warnings
  sparse: Fix an "Using plain integer as NULL pointer" warning
This commit is contained in:
Junio C Hamano 2011-10-05 12:36:22 -07:00
commit 6cf5b81f32
2 changed files with 8 additions and 9 deletions

View File

@ -173,7 +173,7 @@ _obstack_begin (struct obstack *h,
alignment - 1); alignment - 1);
h->chunk_limit = chunk->limit h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size; = (char *) chunk + h->chunk_size;
chunk->prev = 0; chunk->prev = NULL;
/* The initial chunk now contains no empty object. */ /* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0; h->maybe_empty_object = 0;
h->alloc_failed = 0; h->alloc_failed = 0;
@ -221,7 +221,7 @@ _obstack_begin_1 (struct obstack *h, int size, int alignment,
alignment - 1); alignment - 1);
h->chunk_limit = chunk->limit h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size; = (char *) chunk + h->chunk_size;
chunk->prev = 0; chunk->prev = NULL;
/* The initial chunk now contains no empty object. */ /* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0; h->maybe_empty_object = 0;
h->alloc_failed = 0; h->alloc_failed = 0;
@ -321,12 +321,12 @@ _obstack_allocated_p (struct obstack *h, void *obj)
/* We use >= rather than > since the object cannot be exactly at /* We use >= rather than > since the object cannot be exactly at
the beginning of the chunk but might be an empty object exactly the beginning of the chunk but might be an empty object exactly
at the end of an adjacent chunk. */ 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; plp = lp->prev;
lp = plp; lp = plp;
} }
return lp != 0; return lp != NULL;
} }
/* Free objects in obstack H, including OBJ and everything allocate /* Free objects in obstack H, including OBJ and everything allocate
@ -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. /* We use >= because there cannot be an object at the beginning of a chunk.
But there can be an empty object at that address But there can be an empty object at that address
at the end of another chunk. */ 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; plp = lp->prev;
CALL_FREEFUN (h, lp); CALL_FREEFUN (h, lp);
@ -359,7 +359,7 @@ obstack_free (struct obstack *h, void *obj)
h->chunk_limit = lp->limit; h->chunk_limit = lp->limit;
h->chunk = lp; h->chunk = lp;
} }
else if (obj != 0) else if (obj != NULL)
/* obj is not in any of the chunks! */ /* obj is not in any of the chunks! */
abort (); abort ();
} }
@ -376,7 +376,7 @@ _obstack_memory_used (struct obstack *h)
register struct _obstack_chunk* lp; register struct _obstack_chunk* lp;
register int nbytes = 0; 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; nbytes += lp->limit - (char *) lp;
} }
@ -395,7 +395,6 @@ _obstack_memory_used (struct obstack *h)
# endif # endif
static void static void
__attribute__ ((noreturn))
print_and_abort (void) print_and_abort (void)
{ {
/* Don't change any of these strings. Yes, it would be possible to add /* Don't change any of these strings. Yes, it would be possible to add

View File

@ -674,7 +674,7 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
copy of the preceding main search loops. */ copy of the preceding main search loops. */
if (lim - mch > kwset->maxd) if (lim - mch > kwset->maxd)
lim = mch + kwset->maxd; lim = mch + kwset->maxd;
lmch = 0; lmch = NULL;
d = 1; d = 1;
while (lim - end >= d) while (lim - end >= d)
{ {