From c88ffcc6f4f46223c219014729f33f6cb9649928 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Mon, 10 Feb 2020 20:29:30 +0100 Subject: [PATCH] Darwin: -Wformat-diag fix (PR93641) The length used for the comparison for 'CFStringRef' was only comparing for 'CFString', potentially allowing mismatched identifiers. 2020-02-10 Iain Sandoe PR other/93641 * config/darwin-c.c (darwin_cfstring_ref_p): Fix up last argument of strncmp. --- gcc/ChangeLog | 6 ++++++ gcc/config/darwin-c.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 39de837b326..3892d9aed53 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-02-10 Iain Sandoe + + PR other/93641 + * config/darwin-c.c (darwin_cfstring_ref_p): Fix up last + argument of strncmp. + 2020-02-10 Hans-Peter Nilsson Try to generate zero-based comparisons. diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 6b2ba2f961c..85d775f056a 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -809,7 +809,8 @@ darwin_cfstring_ref_p (const_tree strp) tn = DECL_NAME (tn); return (tn && IDENTIFIER_POINTER (tn) - && !strncmp (IDENTIFIER_POINTER (tn), "CFStringRef", 8)); + && !strncmp (IDENTIFIER_POINTER (tn), "CFStringRef", + strlen ("CFStringRef"))); } /* At present the behavior of this is undefined and it does nothing. */ -- 2.30.2