diff mbox

[6/7] Silence obstack.c -Wc++compat warning

Message ID 20151107081121.GG17177@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Nov. 7, 2015, 8:11 a.m. UTC
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.

Comments

Jeff Law Nov. 8, 2015, 11:29 p.m. UTC | #1
On 11/07/2015 01:11 AM, Alan Modra wrote:
> 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.
OK.  Please consider feeding this to gnulib since it looks like 
something they may want to fix.

jeff
diff mbox

Patch

diff --git a/libiberty/obstack.c b/libiberty/obstack.c
index 9f34da1..6d8d672 100644
--- a/libiberty/obstack.c
+++ b/libiberty/obstack.c
@@ -138,9 +138,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;
@@ -202,7 +203,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;