lkml.org 
[lkml]   [2014]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] arm: memset: zero out upper bytes in r1
Date
Andrey Ryabinin <a.ryabinin <at> samsung.com> writes:

>
> memset doesn't work right for following example:
>
> signed char c = 0xF0;
> memset(addr, c, size);
>
> Variable c is signed, so after typcasting to int the value will be 0xFFFFFFF0.
> This value will be passed through r1 regitster to memset function.
> memset doesn't zero out upper bytes in r1, so memory will be filled
> with 0xFFFFFFF0 instead of expected 0xF0F0F0F0.

It behaves the same as a generic implementation in lib/string.c, moreover
gcc built-in behaves the same. So it looks like expected behavior and POSIX
Programmer's Manual (man 3posix memset) explicitly says that "c" is
converted to unsigned char.

Cheers
Vladimir



\
 
 \ /
  Last update: 2014-05-08 11:01    [W:0.055 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site