[compiler-rt] r215436 - [ASan] Use more appropriate return types for strlen/wcslen to avoid MSVC warnings

Timur Iskhodzhanov timurrrr at google.com
Tue Aug 26 05:42:30 PDT 2014


OK, I've disabled this warning in r216450.

2014-08-22 0:15 GMT+04:00 Timur Iskhodzhanov <timurrrr at google.com>:
> 2014-08-21 20:22 GMT+04:00 Alexander Potapenko <glider at google.com>:
>> Done in r216184.
>>
>> On Thu, Aug 21, 2014 at 8:16 PM, Alexander Potapenko <glider at google.com> wrote:
>>> "unsigned" is not an appropriate replacement for uptr here, as size_t
>>> is pointer-sized (at least on Linux and OSX)
>>> I'm going to replace this with SIZE_T which is already used in similar cases.
>
> MSVC is grumpy :(
>
> lib\asan\asan_interceptors.cc(553) : warning C4391: 'SIZE_T
> strlen(const char *)' : incorrect return type for intrinsic function,
> expected 'unsigned int'
> lib\asan\asan_interceptors.cc(568) : warning C4391: 'SIZE_T
> wcslen(const wchar_t *)' : incorrect return type for intrinsic
> function, expected 'unsigned int'
>
>>> On Tue, Aug 12, 2014 at 3:02 PM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
>>>> Author: timurrrr
>>>> Date: Tue Aug 12 06:02:53 2014
>>>> New Revision: 215436
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=215436&view=rev
>>>> Log:
>>>> [ASan] Use more appropriate return types for strlen/wcslen to avoid MSVC warnings
>>>>
>>>> Modified:
>>>>     compiler-rt/trunk/lib/asan/asan_interceptors.cc
>>>>     compiler-rt/trunk/lib/asan/asan_interceptors.h
>>>>
>>>> Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
>>>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=215436&r1=215435&r2=215436&view=diff
>>>> ==============================================================================
>>>> --- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
>>>> +++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Tue Aug 12 06:02:53 2014
>>>> @@ -550,7 +550,7 @@ INTERCEPTOR(char*, strdup, const char *s
>>>>  }
>>>>  #endif
>>>>
>>>> -INTERCEPTOR(uptr, strlen, const char *s) {
>>>> +INTERCEPTOR(unsigned, strlen, const char *s) {
>>>>    if (UNLIKELY(!asan_inited)) return internal_strlen(s);
>>>>    // strlen is called from malloc_default_purgeable_zone()
>>>>    // in __asan::ReplaceSystemAlloc() on Mac.
>>>> @@ -558,15 +558,15 @@ INTERCEPTOR(uptr, strlen, const char *s)
>>>>      return REAL(strlen)(s);
>>>>    }
>>>>    ENSURE_ASAN_INITED();
>>>> -  uptr length = REAL(strlen)(s);
>>>> +  unsigned length = REAL(strlen)(s);
>>>>    if (flags()->replace_str) {
>>>>      ASAN_READ_RANGE(s, length + 1);
>>>>    }
>>>>    return length;
>>>>  }
>>>>
>>>> -INTERCEPTOR(uptr, wcslen, const wchar_t *s) {
>>>> -  uptr length = REAL(wcslen)(s);
>>>> +INTERCEPTOR(unsigned, wcslen, const wchar_t *s) {
>>>> +  unsigned length = REAL(wcslen)(s);
>>>>    if (!asan_init_is_running) {
>>>>      ENSURE_ASAN_INITED();
>>>>      ASAN_READ_RANGE(s, (length + 1) * sizeof(wchar_t));
>>>>
>>>> Modified: compiler-rt/trunk/lib/asan/asan_interceptors.h
>>>> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.h?rev=215436&r1=215435&r2=215436&view=diff
>>>> ==============================================================================
>>>> --- compiler-rt/trunk/lib/asan/asan_interceptors.h (original)
>>>> +++ compiler-rt/trunk/lib/asan/asan_interceptors.h Tue Aug 12 06:02:53 2014
>>>> @@ -86,7 +86,7 @@ DECLARE_REAL(int, memcmp, const void *a1
>>>>  DECLARE_REAL(void*, memcpy, void *to, const void *from, uptr size)
>>>>  DECLARE_REAL(void*, memset, void *block, int c, uptr size)
>>>>  DECLARE_REAL(char*, strchr, const char *str, int c)
>>>> -DECLARE_REAL(uptr, strlen, const char *s)
>>>> +DECLARE_REAL(unsigned, strlen, const char *s)
>>>>  DECLARE_REAL(char*, strncpy, char *to, const char *from, uptr size)
>>>>  DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen)
>>>>  DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>>
>>>
>>> --
>>> Alexander Potapenko
>>> Software Engineer
>>> Google Moscow
>>
>>
>>
>> --
>> Alexander Potapenko
>> Software Engineer
>> Google Moscow



More information about the llvm-commits mailing list