* Re: [RFA/ARI fix] Remove use of abort function in common/buffer.c
[not found] <4fbb59b7.44e2440a.48c4.ffffab13SMTPIN_ADDED@mx.google.com>
@ 2012-05-22 9:34 ` Pedro Alves
2012-05-22 12:05 ` [RFA-v2/ARI " Pierre Muller
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2012-05-22 9:34 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches
On 05/22/2012 10:17 AM, Pierre Muller wrote:
> ARI clearly states that abort function
> should never be used, and to use internal_error
> instead.
>
> I first suspected that this was related to missing declarations in
> common directory, but internal_error does
> exist there also.
>
> Finally, looking at common/buffer.c source, I found that
> gdb_assert was probably a better fit here
> (the macro does call internal_error).
>
>
> Is this patch OK or what else should we use here?
We should just remove the abort; it's dead code. xrealloc already handles
that for us. common/common-utils.c:xrealloc:
...
/* (...) It never returns NULL. */
...
if (val == NULL)
malloc_failure (size);
return val;
}
--
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFA-v2/ARI fix] Remove use of abort function in common/buffer.c
2012-05-22 9:34 ` [RFA/ARI fix] Remove use of abort function in common/buffer.c Pedro Alves
@ 2012-05-22 12:05 ` Pierre Muller
2012-05-22 12:18 ` Joel Brobecker
0 siblings, 1 reply; 7+ messages in thread
From: Pierre Muller @ 2012-05-22 12:05 UTC (permalink / raw)
To: 'Pedro Alves'; +Cc: gdb-patches
> We should just remove the abort; it's dead code. xrealloc already handles
> that for us. common/common-utils.c:xrealloc:
Pedro, you are right of course...
Here is an update that just removes
the call to abort, and added a small
comment to explain.
Is this OK?
Pierre Muller
GDB pascal language maintainer
2012-05-22 Pierre Muller <muller@ics.u-strasbg.fr>
* common/buffer.c (buffer_grow): ARI fix: Remove unneeded
call to abort.
Index: common/buffer.c
===================================================================
RCS file: /cvs/src/src/gdb/common/buffer.c,v
retrieving revision 1.3
diff -u -p -r1.3 buffer.c
--- common/buffer.c 11 May 2012 22:24:22 -0000 1.3
+++ common/buffer.c 22 May 2012 12:02:18 -0000
@@ -47,8 +47,8 @@ buffer_grow (struct buffer *buffer, cons
while (buffer->used_size + size > new_buffer_size)
new_buffer_size *= 2;
new_buffer = xrealloc (buffer->buffer, new_buffer_size);
- if (!new_buffer)
- abort ();
+ /* new_buffer is non NULL otherwise
+ xrealloc calls malloc_failure which does not return here. */
memcpy (new_buffer + buffer->used_size, data, size);
buffer->buffer = new_buffer;
buffer->buffer_size = new_buffer_size;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA-v2/ARI fix] Remove use of abort function in common/buffer.c
2012-05-22 12:05 ` [RFA-v2/ARI " Pierre Muller
@ 2012-05-22 12:18 ` Joel Brobecker
2012-05-22 12:39 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Joel Brobecker @ 2012-05-22 12:18 UTC (permalink / raw)
To: Pierre Muller; +Cc: 'Pedro Alves', gdb-patches
Hi Pierre, Hi Pedro,
Thanks for taking care of this, Pierre.
> + /* new_buffer is non NULL otherwise
> + xrealloc calls malloc_failure which does not return here. */
I suggest a slightly different way of saying this:
/* xrealloc guaranties that new_buffer cannot be null. */
It avoids the problem with the location of the line break and any issue
with punctuation...
--
Joel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA-v2/ARI fix] Remove use of abort function in common/buffer.c
2012-05-22 12:18 ` Joel Brobecker
@ 2012-05-22 12:39 ` Pedro Alves
2012-05-22 15:15 ` [RFA-v3/ARI " Pierre Muller
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2012-05-22 12:39 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Pierre Muller, gdb-patches
On 05/22/2012 01:18 PM, Joel Brobecker wrote:
> Hi Pierre, Hi Pedro,
>
> Thanks for taking care of this, Pierre.
>
>> + /* new_buffer is non NULL otherwise
>> + xrealloc calls malloc_failure which does not return here. */
>
> I suggest a slightly different way of saying this:
>
> /* xrealloc guaranties that new_buffer cannot be null. */
>
> It avoids the problem with the location of the line break and any issue
> with punctuation...
>
Fine with me, but I'd suggest to just say nothing. The whole point of the xrealloc,
xmalloc, etc. functions is to abort on failure instead of returning NULL. We have
about 150 or so xrealloc calls in the tree, about 70 xcalloc calls, and
about 700 xmalloc calls. We don't put just comment on most (any?) of those, and
I don't see what makes this particular instance special.
--
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFA-v3/ARI fix] Remove use of abort function in common/buffer.c
2012-05-22 12:39 ` Pedro Alves
@ 2012-05-22 15:15 ` Pierre Muller
2012-05-22 15:18 ` Pedro Alves
0 siblings, 1 reply; 7+ messages in thread
From: Pierre Muller @ 2012-05-22 15:15 UTC (permalink / raw)
To: 'Pedro Alves', gdb-patches
> Fine with me, but I'd suggest to just say nothing. The whole point of the
> xrealloc,
> xmalloc, etc. functions is to abort on failure instead of returning NULL.
> We have
> about 150 or so xrealloc calls in the tree, about 70 xcalloc calls, and
> about 700 xmalloc calls. We don't put just comment on most (any?) of
those,
> and
> I don't see what makes this particular instance special.
You are right,
OK for that even simpler patch?
2012-05-22 Pierre Muller <muller@ics.u-strasbg.fr>
* common/buffer.c (buffer_grow): ARI fix: Remove unneeded
call to abort.
Index: common/buffer.c
===================================================================
RCS file: /cvs/src/src/gdb/common/buffer.c,v
retrieving revision 1.3
diff -u -p -r1.3 buffer.c
--- common/buffer.c 11 May 2012 22:24:22 -0000 1.3
+++ common/buffer.c 22 May 2012 15:13:24 -0000
@@ -47,8 +47,6 @@ buffer_grow (struct buffer *buffer, cons
while (buffer->used_size + size > new_buffer_size)
new_buffer_size *= 2;
new_buffer = xrealloc (buffer->buffer, new_buffer_size);
- if (!new_buffer)
- abort ();
memcpy (new_buffer + buffer->used_size, data, size);
buffer->buffer = new_buffer;
buffer->buffer_size = new_buffer_size;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFA-v3/ARI fix] Remove use of abort function in common/buffer.c
2012-05-22 15:15 ` [RFA-v3/ARI " Pierre Muller
@ 2012-05-22 15:18 ` Pedro Alves
2012-05-22 15:57 ` Pierre Muller
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2012-05-22 15:18 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches
On 05/22/2012 04:14 PM, Pierre Muller wrote:
> OK for that even simpler patch?
OK. Thanks.
--
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [RFA-v3/ARI fix] Remove use of abort function in common/buffer.c
2012-05-22 15:18 ` Pedro Alves
@ 2012-05-22 15:57 ` Pierre Muller
0 siblings, 0 replies; 7+ messages in thread
From: Pierre Muller @ 2012-05-22 15:57 UTC (permalink / raw)
To: 'Pedro Alves'; +Cc: gdb-patches
> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Pedro Alves
> Envoyé : mardi 22 mai 2012 17:19
> À : Pierre Muller
> Cc : gdb-patches@sourceware.org
> Objet : Re: [RFA-v3/ARI fix] Remove use of abort function in
common/buffer.c
>
> On 05/22/2012 04:14 PM, Pierre Muller wrote:
>
> > OK for that even simpler patch?
>
>
> OK. Thanks.
Thanks for the feedback,
patch committed
http://sourceware.org/ml/gdb-cvs/2012-05/msg00164.html
Pierre
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-05-22 15:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <4fbb59b7.44e2440a.48c4.ffffab13SMTPIN_ADDED@mx.google.com>
2012-05-22 9:34 ` [RFA/ARI fix] Remove use of abort function in common/buffer.c Pedro Alves
2012-05-22 12:05 ` [RFA-v2/ARI " Pierre Muller
2012-05-22 12:18 ` Joel Brobecker
2012-05-22 12:39 ` Pedro Alves
2012-05-22 15:15 ` [RFA-v3/ARI " Pierre Muller
2012-05-22 15:18 ` Pedro Alves
2012-05-22 15:57 ` Pierre Muller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox