Re: [PATCH v2] arch: s390: appldata: using strncpy() and strnlen() instead of sprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chen Gang <gang.chen@xxxxxxxxxxx> wrote:

> -		len = sprintf(buf, appldata_timer_active ? "1\n" : "0\n");
> +		strncpy(buf, appldata_timer_active ? "1\n" : "0\n",
> +			ARRAY_SIZE(buf));
> +		len = strnlen(buf, ARRAY_SIZE(buf));

Since the strings here are a fixed, preknown size, you should use memcpy (or
just fill in the array directly which would likely take fewer instructions
since the strings are so short and vary by one character) and hard-code the
length or use sizeof() instead of strnlen().

David
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux