From patchwork Mon Jun 9 13:42:37 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: 1371 Received: (qmail 21536 invoked by alias); 9 Jun 2014 13:42:43 -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 21526 invoked by uid 89); 9 Jun 2014 13:42:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 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-wg0-f42.google.com Received: from mail-wg0-f42.google.com (HELO mail-wg0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 09 Jun 2014 13:42:41 +0000 Received: by mail-wg0-f42.google.com with SMTP id z12so2255179wgg.13 for ; Mon, 09 Jun 2014 06:42:38 -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:date:message-id:subject:from:to:cc :content-type; bh=8FMaY2FKoUsOl/atJ9SDElSoN7kTT1Szduj0B1khqs8=; b=lrkvjcrggz2Sh18TVJ6wtZH8nt0HFP8YpZi1HZsFO3k+A5AU575paRuARlYAsRKjEr GrxtJbIZ81hZ+tqrdL4MDDS6ytYZaWnjpXUuSgCUiZG/A0bO64WJfD9u93Ljg5BF0ybd Fo3vlfn4XoBbKkCRUT+xFN1I6HpYnKU1RNR8rpAZDG1ogWBtBni05DEjZCuXuo5FB5fJ m6XkbgzlQ6nwF4O/6JkkhD9WrS4sOn9OmH0sEP18gwh9iHh55LPZmxLftZ6B0hDT8ypp FnRwAadMO6+BB4+0JgZ2+JBknBG2Z84MYWoSi4bznHEEJDMmq+mENubw2+ZcKrO9n5YV 6h2Q== X-Gm-Message-State: ALoCoQnv8RR3ZJFaA6Zjp8hnBGpZkohfOIAS5JBrGlvt0gFgbaaxGBN6FUkDiZHIjI/lnc+lSf2D MIME-Version: 1.0 X-Received: by 10.180.91.162 with SMTP id cf2mr31181391wib.57.1402321357854; Mon, 09 Jun 2014 06:42:37 -0700 (PDT) Received: by 10.217.51.7 with HTTP; Mon, 9 Jun 2014 06:42:37 -0700 (PDT) Date: Mon, 9 Jun 2014 06:42:37 -0700 Message-ID: Subject: [PATCH] Wrap PyObject_Get/HasAttrString in a function with second arg having const qualifier. From: Siva Chandra To: gdb-patches Cc: Pedro Alves , Ulrich Weigand X-IsSubscribed: yes The attached patch wraps PyObject_GetAttrString and PyObject_HasAttrString in internal functions which have const qualifier for the second argument. This is required because these functions were missing the const qualifier in Python-2.4. ChangeLog 2014-06-09 Siva Chandra Reddy * python/python-internal.h (gdb_PyObject_GetAttrString) (gdb_PyObject_HasAttrString): New inline function definitions. * py-value.c (get_field_flag): Remove the now unnecessary cast to (char *) of the second argument to PyObject_GetAttrString. diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 54da67a..9821990 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -555,7 +555,7 @@ 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..7cf03b5 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. Hence, we wrap it in a function to avoid errors when compiled + with -Werror against Python 2.4. */ + +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. Hence, we wrap it also in a function to avoid errors when + compiled with -Werror against Python 2.4. */ + +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"