[committed] Darwin: -Wformat-diag fix (PR93641)

Message ID 1F90254C-3F2F-4FC8-8EF3-58E045C4D49B@googlemail.com
State New
Headers show
Series
  • [committed] Darwin: -Wformat-diag fix (PR93641)
Related show

Commit Message

Iain Sandoe Feb. 10, 2020, 7:36 p.m.
Hi

As show in the PR, The length used for the comparison for 'CFStringRef’ was
only comparing for 'CFString', potentially allowing mismatched identifiers.

fixed thus,
tested on x86_64-darwin16,
applied to master
thanks
Iain

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  <iain@sandoe.co.uk>

           PR other/93641
           * config/darwin-c.c (darwin_cfstring_ref_p): Fix up last
           argument of strncmp.

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.  */