bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Silence obstack.c -Wc++compat warning


From: Alan Modra
Subject: Silence obstack.c -Wc++compat warning
Date: Mon, 9 Nov 2015 18:13:38 +1030
User-agent: Mutt/1.5.23 (2014-03-12)

Fixes
warning: request for implicit conversion from ‘void *’ to ‘struct 
_obstack_chunk *’ not permitted in C++ [-Wc++-compat]

I moved the assignment to h->chunk to fix an overlong line, then
decided it would be better after the alloc failure check just to do
things the same way as in _obstack_newchunk.

        * obstack.c (_obstack_newchunk): Silence -Wc++compat warning.
        (_obstack_begin_worker): Likewise.  Move assignment to h->chunk
        after alloc failure check.

diff --git a/lib/obstack.c b/lib/obstack.c
index 3b99dfa..5ad3169 100644
--- a/lib/obstack.c
+++ b/lib/obstack.c
@@ -133,9 +133,10 @@ _obstack_begin_worker (struct obstack *h,
   h->chunk_size = size;
   h->alignment_mask = alignment - 1;
 
-  chunk = h->chunk = call_chunkfun (h, h->chunk_size);
+  chunk = (struct _obstack_chunk *) call_chunkfun (h, h->chunk_size);
   if (!chunk)
     (*obstack_alloc_failed_handler) ();
+  h->chunk = chunk;
   h->next_free = h->object_base = __PTR_ALIGN ((char *) chunk, chunk->contents,
                                                alignment - 1);
   h->chunk_limit = chunk->limit = (char *) chunk + h->chunk_size;
@@ -197,7 +198,7 @@ _obstack_newchunk (struct obstack *h, _OBSTACK_SIZE_T 
length)
 
   /* Allocate and initialize the new chunk.  */
   if (obj_size <= sum1 && sum1 <= sum2)
-    new_chunk = call_chunkfun (h, new_size);
+    new_chunk = (struct _obstack_chunk *) call_chunkfun (h, new_size);
   if (!new_chunk)
     (*obstack_alloc_failed_handler)();
   h->chunk = new_chunk;

-- 
Alan Modra
Australia Development Lab, IBM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]