From patchwork Tue Jun 10 18:56:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siva Chandra Reddy X-Patchwork-Id: 1426 Received: (qmail 1314 invoked by alias); 10 Jun 2014 18:56:46 -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 1293 invoked by uid 89); 10 Jun 2014 18:56:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f176.google.com Received: from mail-wi0-f176.google.com (HELO mail-wi0-f176.google.com) (209.85.212.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 10 Jun 2014 18:56:43 +0000 Received: by mail-wi0-f176.google.com with SMTP id n3so4043486wiv.15 for ; Tue, 10 Jun 2014 11:56:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=ZsTV+7oOE0JVWak+cdsYhI7lQDL6RhX81XmzTSUD4j0=; b=e/ti0wm5+8pVuip5vdh/XK7AxXemXgklOuiTJDw4Ipp/9vEMfSQpOGR5OzSzd4DPv4 BAEYY8ByCG4KGqYcCgoEMCoYt2gmxW5Z+CGKOhj/2k27xeyV9yfUZ3V6h+sCgbtQC02F 1Fw5EmFu1XQg2EyFxNoJOYJ6vwhspskufCp/L5aH9tjeirA2XYgtbkhUC5TdytkVLhhl zFRQ8UIFOQpdFLrf0PveLnIkx0MGIUQp5A1nU42QgrmofhCiQFS16+4LZZj7sYLf6rPx gmWB24KOgrNe8knKhrXV5EAwA8HwSGjde2CWcofJYvKfE9eZfDuIj1xk2uxWsjQj4IzY c3jw== X-Gm-Message-State: ALoCoQl0zUpndw0KXKF+OFo5w228EjBmMoPF/tFm5xiDSEgDQImaOvQ/thZwwT1VJOKcTrabsY9z MIME-Version: 1.0 X-Received: by 10.180.89.233 with SMTP id br9mr17916455wib.14.1402426600601; Tue, 10 Jun 2014 11:56:40 -0700 (PDT) Received: by 10.217.50.137 with HTTP; Tue, 10 Jun 2014 11:56:40 -0700 (PDT) In-Reply-To: References: <5395BC0D.50709@redhat.com> Date: Tue, 10 Jun 2014 11:56:40 -0700 Message-ID: Subject: Re: [PATCH] Wrap PyObject_Get/HasAttrString in a function with second arg having const qualifier. From: Siva Chandra To: Pedro Alves Cc: gdb-patches , Ulrich Weigand X-IsSubscribed: yes On Tue, Jun 10, 2014 at 11:56 AM, Siva Chandra wrote: > Thanks for the quick review. I have pushed the attached patch which > includes the doc fixes suggested by Pedro. Ah! The patch is attached now! diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 54da67a..8532da6 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -554,8 +554,7 @@ static int get_field_flag (PyObject *field, const char *flag_name) { int flag_value; - /* Python 2.4 did not have a 'const' here. */ - PyObject *flag_object = PyObject_GetAttrString (field, (char *) flag_name); + PyObject *flag_object = PyObject_GetAttrString (field, flag_name); if (flag_object == NULL) return -1; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 9c06621..0198e9d 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -187,6 +187,32 @@ gdb_Py_DECREF (void *op) /* ARI: editCase function */ #undef Py_DECREF #define Py_DECREF(op) gdb_Py_DECREF (op) +/* The second argument to PyObject_GetAttrString was missing the 'const' + qualifier in Python-2.4. Hence, we wrap it in a function to avoid errors + when compiled with -Werror. */ + +static inline PyObject * +gdb_PyObject_GetAttrString (PyObject *obj, + const char *attr) /* ARI: editCase function */ +{ + return PyObject_GetAttrString (obj, (char *) attr); +} + +#define PyObject_GetAttrString(obj, attr) gdb_PyObject_GetAttrString (obj, attr) + +/* The second argument to PyObject_HasAttrString was also missing the 'const' + qualifier in Python-2.4. Hence, we wrap it also in a function to avoid + errors when compiled with -Werror. */ + +static inline int +gdb_PyObject_HasAttrString (PyObject *obj, + const char *attr) /* ARI: editCase function */ +{ + return PyObject_HasAttrString (obj, (char *) attr); +} + +#define PyObject_HasAttrString(obj, attr) gdb_PyObject_HasAttrString (obj, attr) + /* In order to be able to parse symtab_and_line_to_sal_object function a real symtab_and_line structure is needed. */ #include "symtab.h"