From patchwork Fri Aug 28 15:51:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 8497 Received: (qmail 90480 invoked by alias); 28 Aug 2015 15:51:40 -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 89768 invoked by uid 89); 28 Aug 2015 15:51:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 28 Aug 2015 15:51:39 +0000 Received: from EUSAAHC002.ericsson.se (Unknown_Domain [147.117.188.78]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id 93.80.26730.59910E55; Fri, 28 Aug 2015 10:19:33 +0200 (CEST) Received: from elxcz23q12-y4.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.78) with Microsoft SMTP Server (TLS) id 14.3.210.2; Fri, 28 Aug 2015 11:51:36 -0400 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] Constify variables in ada-lang.c Date: Fri, 28 Aug 2015 11:51:32 -0400 Message-ID: <1440777092-18775-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes I found this const/not const mixup found by building in C++ mode. I would push this as obvious, but I am not sure I understand what happens in scan_discrim_bound, so I'd like it to be reviewed. Thanks! gdb/ChangeLog: * ada-lang.c (value_val_atr): Constify variables. (xget_renaming_scope): Likewise. (num_visible_fields): Likewise. (ada_is_redundant_range_encoding): Likewise. (ada_float_to_fixed): Likewise. (scan_discrim_bound): Likewise. (to_fixed_range_type): Likewise. --- gdb/ada-lang.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7e6b6dc..823e930 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -215,7 +215,7 @@ static struct value *value_val_atr (struct type *, struct value *); static struct symbol *standard_lookup (const char *, const struct block *, domain_enum); -static struct value *ada_search_struct_field (char *, struct value *, int, +static struct value *ada_search_struct_field (const char *, struct value *, int, struct type *); static struct value *ada_value_primitive_field (struct value *, int, int, @@ -5024,8 +5024,8 @@ xget_renaming_scope (struct type *renaming_type) and then backtrack until we find the first "__". */ const char *name = type_name_no_tag (renaming_type); - char *suffix = strstr (name, "___XR"); - char *last; + const char *suffix = strstr (name, "___XR"); + const char *last; int scope_len; char *scope; @@ -7217,7 +7217,7 @@ num_visible_fields (struct type *type) Searches recursively through wrapper fields (e.g., '_parent'). */ static struct value * -ada_search_struct_field (char *name, struct value *arg, int offset, +ada_search_struct_field (const char *name, struct value *arg, int offset, struct type *type) { int i; @@ -8581,7 +8581,7 @@ ada_is_redundant_range_encoding (struct type *range_type, struct type *encoding_type) { struct type *fixed_range_type; - char *bounds_str; + const char *bounds_str; int n; LONGEST lo, hi; @@ -11423,13 +11423,12 @@ ada_float_to_fixed (struct type *type, DOUBLEST x) not alter *PX and *PNEW_K if unsuccessful. */ static int -scan_discrim_bound (char *str, int k, struct value *dval, LONGEST * px, +scan_discrim_bound (const char *str, int k, struct value *dval, LONGEST * px, int *pnew_k) { static char *bound_buffer = NULL; static size_t bound_buffer_len = 0; - char *bound; - char *pend; + const char *pend, *bound; struct value *bound_val; if (dval == NULL || str == NULL || str[k] == '\0') @@ -11446,11 +11445,12 @@ scan_discrim_bound (char *str, int k, struct value *dval, LONGEST * px, GROW_VECT (bound_buffer, bound_buffer_len, pend - (str + k) + 1); bound = bound_buffer; strncpy (bound_buffer, str + k, pend - (str + k)); - bound[pend - (str + k)] = '\0'; + bound_buffer[pend - (str + k)] = '\0'; k = pend - str; } bound_val = ada_search_struct_field (bound, dval, 0, value_type (dval)); + if (bound_val == NULL) return 0; @@ -11522,7 +11522,7 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) { const char *name; struct type *base_type; - char *subtype_info; + const char *subtype_info; gdb_assert (raw_type != NULL); gdb_assert (TYPE_NAME (raw_type) != NULL); @@ -11552,7 +11552,7 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) int prefix_len = subtype_info - name; LONGEST L, U; struct type *type; - char *bounds_str; + const char *bounds_str; int n; GROW_VECT (name_buf, name_len, prefix_len + 5);