From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Extend SystemTap SDT probe argument parser
Date: Tue, 17 Dec 2013 21:06:00 -0000 [thread overview]
Message-ID: <m3vbynuqzb.fsf@redhat.com> (raw)
In-Reply-To: <52B0AA0E.9020302@redhat.com> (Pedro Alves's message of "Tue, 17 Dec 2013 19:46:22 +0000")
On Tuesday, December 17 2013, Pedro Alves wrote:
> On 12/17/2013 05:27 PM, Sergio Durigan Junior wrote:
>> +/* Helper function to print a list of strings, represented as "const
>> + char *const *". The list is printed comma-separated. */
>> +
>> +static char *
>> +pstring_list (const char *const *list)
>> +{
>> + static char ret[100];
>> + const char *const *p;
>> + size_t offset = 0;
>> +
>> + if (list == NULL)
>> + return "(null)";
>> +
>> + ret[0] = '\0';
>> + for (p = list; *p != NULL && offset < sizeof (ret); ++p)
>> + {
>> + size_t s = xsnprintf (ret + offset, sizeof (ret) - offset, "%s, ", *p);
>> + offset += 2 + s;
>> + }
>> +
>> + gdb_assert (offset - 2 < sizeof (ret));
>
> Note this will assert if the list is empty (but not NULL), i.e., { NULL },
> because offset will be 0, and "offset - 2" will wrap around
> (offset is unsigned size_t.) I suggest either moving the assert within
> the if below, or handle that case especially, printing "(empty)"
> or some such.
Thanks, nice catch. I moved the assert within the "if".
--
Sergio
next prev parent reply other threads:[~2013-12-17 21:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 3:56 Sergio Durigan Junior
2013-12-16 17:01 ` Sergio Durigan Junior
2013-12-16 17:09 ` Mark Kettenis
2013-12-16 17:16 ` Sergio Durigan Junior
2013-12-17 11:03 ` Pedro Alves
2013-12-17 17:28 ` Sergio Durigan Junior
2013-12-17 19:46 ` Pedro Alves
2013-12-17 21:06 ` Sergio Durigan Junior [this message]
2013-12-19 20:58 ` Sergio Durigan Junior
2013-12-19 21:09 ` Mark Kettenis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3vbynuqzb.fsf@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).