From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27719 invoked by alias); 5 Mar 2013 07:45:35 -0000 Received: (qmail 27708 invoked by uid 22791); 5 Mar 2013 07:45:33 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Mar 2013 07:45:27 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1UCmYw-0003SN-Mw from Yao_Qi@mentor.com ; Mon, 04 Mar 2013 23:45:26 -0800 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 4 Mar 2013 23:45:26 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Mon, 4 Mar 2013 23:45:25 -0800 Message-ID: <5135A26A.6030608@codesourcery.com> Date: Tue, 05 Mar 2013 07:45:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Pedro Alves CC: Subject: Re: [PATCH 1/2] use zuinteger_unlimited for some remote commands References: <1360934868-5807-1-git-send-email-yao@codesourcery.com> <1360934868-5807-2-git-send-email-yao@codesourcery.com> <51349F6E.8020101@redhat.com> <5134B192.8080507@codesourcery.com> <5134C9DD.2070205@redhat.com> In-Reply-To: <5134C9DD.2070205@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes 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 X-SW-Source: 2013-03/txt/msg00136.txt.bz2 On 03/05/2013 12:20 AM, Pedro Alves wrote: > But I ask, what's either: > > - the point of making it internally signed > with things like: > > if (*(int *) c->var != val) > > and forbidding INT_MAX..UINT_MAX-1. (Not that I'm > arguing it should). The care to only accept -1 > and not any other negative number made me think > numbers in that range should be accepted. Internally, we use -1 for unlimited, so it is signed. Externally, it is unsigned, so we have to forbid the range (INT_MAX, UINT_MAX - 1]. > > - the point of making it externally unsigned if > it only accepts [0, INT_MAX]. If the variable because we need -1 for unlimited internally. I don't see anything wrong to define unsigned type whose range is [0, INT_MAX]. > assigned to the command was signed too, then this > range would be both implicit and explicit, meaning, one > weird detail less the user of the API needs to know. If I understand you correctly, this is what you want, extern void add_setshow_zuinteger_unlimited_cmd (char *name, enum command_class class, int *var, ^^^^^^^^ then, IMO, the API is weird, in which the type of parameter VAR (singed) is not consistent with the function (zuinteger_unlimited). Since these CLI stuff provide APIs to other components, it is better to review them externally first. However, I don't insist on that if you believe changing the type of VAR from "unsigned int" to "int" is better, I am OK to change it to: /* ZeroableUnsignedInteger with unlimited value. *VAR is an int, but its range is [0, INT_MAX]. -1 stands for unlimited and other negative numbers are not allowed. */ The patch below is regression tested on x86_64-linux. -- Yao (齐尧) gdb: 2013-03-05 Yao Qi * cli/cli-decode.c (add_setshow_zuinteger_unlimited_cmd): Change parameter VAR's type from "unsigned int" to "int". * command.h (var_zuinteger_unlimited): Update its comments. (add_setshow_zuinteger_unlimited_cmd): Update the declaration. --- gdb/cli/cli-decode.c | 2 +- gdb/command.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 49ccef3..a8f7747 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -708,7 +708,7 @@ add_setshow_zinteger_cmd (char *name, enum command_class class, void add_setshow_zuinteger_unlimited_cmd (char *name, enum command_class class, - unsigned int *var, + int *var, const char *set_doc, const char *show_doc, const char *help_doc, diff --git a/gdb/command.h b/gdb/command.h index 17662b4..a25fe04 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -99,8 +99,9 @@ typedef enum var_types /* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really means zero. */ var_zuinteger, - /* ZeroableUnsignedInteger with unlimited value. *VAR is an unsigned - int, but its range is [0, INT_MAX]. -1 stands for unlimited. */ + /* ZeroableUnsignedInteger with unlimited value. *VAR is an int, + but its range is [0, INT_MAX]. -1 stands for unlimited and + other negative numbers are not allowed. */ var_zuinteger_unlimited, /* Enumerated type. Can only have one of the specified values. *VAR is a char pointer to the name of the element that we @@ -361,7 +362,7 @@ extern void add_setshow_zuinteger_cmd (char *name, extern void add_setshow_zuinteger_unlimited_cmd (char *name, enum command_class class, - unsigned int *var, + int *var, const char *set_doc, const char *show_doc, const char *help_doc, -- 1.7.7.6