From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 602 invoked by alias); 17 Dec 2013 19:46:27 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 582 invoked by uid 89); 17 Dec 2013 19:46:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Dec 2013 19:46:26 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBHJkNeH016575 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Dec 2013 14:46:24 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBHJkMWE026470; Tue, 17 Dec 2013 14:46:23 -0500 Message-ID: <52B0AA0E.9020302@redhat.com> Date: Tue, 17 Dec 2013 19:46:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Sergio Durigan Junior CC: GDB Patches Subject: Re: [PATCH] Extend SystemTap SDT probe argument parser References: <1386734160-29837-1-git-send-email-sergiodj@redhat.com> <52B02F82.3020907@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-12/txt/msg00660.txt.bz2 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. > + if (offset > 0) > + ret[offset - 2] = '\0'; > + > + return ret; I have no further comments. Thanks, -- Pedro Alves