diff mbox

[ubsan,obvious] Fix typo in string empty check

Message ID 3484cb37-ddee-c049-6263-b2a68a74afd0@gmail.com
State New
Headers show

Commit Message

Kirill Yukhin Sept. 2, 2016, 8:22 p.m. UTC
Hello,
Patch in the bottom fixes typo in check of for string emptiness

gcc/
     * gcc/ubsan.c (ubsan_use_new_style_p): Fix check for empty string.

I'll bootstrap/regtest the patch and check it into as obvious if no 
objections.

--
Thanks, K

commit 57ad19906b808386220d628a1ba326e043e0d211
Author: Kirill Yukhin <kirill.yukhin@gmail.com>
Date:   Fri Sep 2 23:14:05 2016 +0300

     Compare first element of char* instead of pointer.

Comments

Jakub Jelinek Sept. 2, 2016, 8:54 p.m. UTC | #1
On Fri, Sep 02, 2016 at 11:22:24PM +0300, Kirill Yukhin wrote:
> Hello,
> Patch in the bottom fixes typo in check of for string emptiness
> 
> gcc/
>     * gcc/ubsan.c (ubsan_use_new_style_p): Fix check for empty string.

No gcc/ in the ChangeLog entry.

> I'll bootstrap/regtest the patch and check it into as obvious if no
> objections.
> 
> --
> Thanks, K
> 
> commit 57ad19906b808386220d628a1ba326e043e0d211
> Author: Kirill Yukhin <kirill.yukhin@gmail.com>
> Date:   Fri Sep 2 23:14:05 2016 +0300
> 
>     Compare first element of char* instead of pointer.
> 
> diff --git a/gcc/ubsan.c b/gcc/ubsan.c
> index 5cbc98d..d3bd8e3 100644
> --- a/gcc/ubsan.c
> +++ b/gcc/ubsan.c
> @@ -1469,7 +1469,7 @@ ubsan_use_new_style_p (location_t loc)
> 
>    expanded_location xloc = expand_location (loc);
>    if (xloc.file == NULL || strncmp (xloc.file, "\1", 2) == 0
> -      || xloc.file == '\0' || xloc.file[0] == '\xff'
> +      || xloc.file[0] == '\0' || xloc.file[0] == '\xff'
>        || xloc.file[1] == '\xff')
>      return false;

Yeah, this is obvious.  You should probably mention
	PR other/77421
and perhaps credit also Jonathan who wrote that first, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77421#c3 , dunno why
it hasn't been submitted to gcc-patches.

	Jakub
Kirill Yukhin Sept. 2, 2016, 9:05 p.m. UTC | #2
On 02.09.2016 23:54, Jakub Jelinek wrote:
Sure, sorry.
gcc/
	* ubsan.c (ubsan_use_new_style_p): Fix check for empty string.
--
Thanks, K
diff mbox

Patch

diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 5cbc98d..d3bd8e3 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -1469,7 +1469,7 @@  ubsan_use_new_style_p (location_t loc)

    expanded_location xloc = expand_location (loc);
    if (xloc.file == NULL || strncmp (xloc.file, "\1", 2) == 0
-      || xloc.file == '\0' || xloc.file[0] == '\xff'
+      || xloc.file[0] == '\0' || xloc.file[0] == '\xff'
        || xloc.file[1] == '\xff')
      return false;