From patchwork Wed Jan 7 03:38:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 4536 Received: (qmail 20339 invoked by alias); 7 Jan 2015 03:38:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20318 invoked by uid 89); 7 Jan 2015 03:38:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 07 Jan 2015 03:38:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 0029011650C; Tue, 6 Jan 2015 22:38:53 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 96zFMU7Fbf8m; Tue, 6 Jan 2015 22:38:52 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 7E8811164C2; Tue, 6 Jan 2015 22:38:52 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 562704100E; Wed, 7 Jan 2015 07:38:48 +0400 (RET) Date: Wed, 7 Jan 2015 07:38:48 +0400 From: Joel Brobecker To: Doug Evans Cc: gdb-patches Subject: Re: [pushed] gdb/python: exception trying to create empty array Message-ID: <20150107033848.GL5445@adacore.com> References: <1420556955-13827-1-git-send-email-brobecker@adacore.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) > I think it might not be immediately obvious to the reader why the test > is "n2 < n1 - 1". > [E.g, there's no > Can you add a comment? Sure. Attached is the patch I just pushed. gdb/ChangeLog: * guile/scm-type.c (tyscm_array_1): Add comment. * python/py-type.c (typy_array_1): Add comment. From e810d75b1c9bef779b29df9d2c609fd5891d5917 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Wed, 7 Jan 2015 07:34:29 +0400 Subject: [PATCH] [python,guile] Add comment beside conditions testing empty arrays. gdb/ChangeLog: * guile/scm-type.c (tyscm_array_1): Add comment. * python/py-type.c (typy_array_1): Add comment. --- gdb/ChangeLog | 5 +++++ gdb/guile/scm-type.c | 2 +- gdb/python/py-type.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8e3737d..0b63d34 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2015-01-07 Joel Brobecker + + * guile/scm-type.c (tyscm_array_1): Add comment. + * python/py-type.c (typy_array_1): Add comment. + 2015-01-06 Joel Brobecker * guile/scm-type.c (tyscm_array_1): Do not raise out-of-range diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 4f46139..196b4a1 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -713,7 +713,7 @@ tyscm_array_1 (SCM self, SCM n1_scm, SCM n2_scm, int is_vector, n1 = 0; } - if (n2 < n1 - 1) + if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1. */ { gdbscm_out_of_range_error (func_name, SCM_ARG3, scm_cons (scm_from_long (n1), diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 8e82c99..bf92363 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -528,7 +528,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector) n1 = 0; } - if (n2 < n1 - 1) + if (n2 < n1 - 1) /* Note: An empty array has n2 == n1 - 1. */ { PyErr_SetString (PyExc_ValueError, _("Array length must not be negative")); -- 1.9.1