From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23501 invoked by alias); 5 Apr 2017 08:49:16 -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 23487 invoked by uid 89); 5 Apr 2017 08:49:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Apr 2017 08:49:13 +0000 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v358iBtn138636 for ; Wed, 5 Apr 2017 04:49:14 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 29m4e6v49c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 05 Apr 2017 04:49:12 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Apr 2017 09:49:09 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 5 Apr 2017 09:49:08 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v358n7qD40894552; Wed, 5 Apr 2017 08:49:07 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D85AE4C040; Wed, 5 Apr 2017 09:48:36 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9AAF4C04A; Wed, 5 Apr 2017 09:48:36 +0100 (BST) Received: from ThinkPad (unknown [9.152.212.148]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 5 Apr 2017 09:48:36 +0100 (BST) Date: Wed, 05 Apr 2017 08:49:00 -0000 From: Philipp Rudo To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 13/18] -Wwrite-strings: Wrap PyGetSetDef for construction with string literals In-Reply-To: <1491326751-16180-14-git-send-email-palves@redhat.com> References: <1491326751-16180-1-git-send-email-palves@redhat.com> <1491326751-16180-14-git-send-email-palves@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17040508-0016-0000-0000-00000471C79C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17040508-0017-0000-0000-0000271C899A Message-Id: <20170405104906.11c5a0c9@ThinkPad> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-05_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704050078 X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00082.txt.bz2 Hi Pedro I found a typo ... On Tue, 4 Apr 2017 18:25:46 +0100 Pedro Alves wrote: [...] > diff --git a/gdb/python/python-internal.h > b/gdb/python/python-internal.h index 55efd75..8fc89cd 100644 > --- a/gdb/python/python-internal.h > +++ b/gdb/python/python-internal.h > @@ -286,6 +286,38 @@ gdb_PySys_SetPath (const GDB_PYSYS_SETPATH_CHAR > *path) > > #define PySys_SetPath gdb_PySys_SetPath > > +/* Wrap PyGetSetDef to allow convenient construction with string > + literals. Unfortunately, PyGetSetDef's 'name' and 'doc' members > + are 'char *' instead of 'const char *', meaning that in order to > + list-initialize PyGetSetDef arrays with string literals (and > + without the wrapping below) would require writing explicit 'char *' > + casts. Instead, we extend PyGetSetDef and add onstexpr ^^^^^^^^ ... here > + constructors that accept const 'name' and 'doc', hiding the ugly > + casts here in a single place. */ > + > +struct gdb_PyGetSetDef : PyGetSetDef > +{ > + constexpr gdb_PyGetSetDef (const char *name_, getter get_, setter > set_, > + const char *doc_, void *closure_) > + : PyGetSetDef {const_cast (name_), get_, set_, > + const_cast (doc_), closure_} > + {} > + > + /* Alternative constructor that allows omitting the closure in list > + initialization. */ > + constexpr gdb_PyGetSetDef (const char *name_, getter get_, setter > set_, > + const char *doc_) > + : gdb_PyGetSetDef {name_, get_, set_, doc_, NULL} > + {} > + > + /* Constructor for the sentinel entries. */ > + constexpr gdb_PyGetSetDef (std::nullptr_t) > + : gdb_PyGetSetDef { NULL, NULL, NULL, NULL, NULL } > + {} > +}; > + > +#define PyGetSetDef gdb_PyGetSetDef > + > /* 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"