[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that n
From: |
Programmingkid |
Subject: |
Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it |
Date: |
Sun, 22 Oct 2017 10:29:47 -0400 |
> On Oct 22, 2017, at 9:37 AM, Peter Maydell <address@hidden> wrote:
>
> On 21 October 2017 at 00:44, Richard Henderson
> <address@hidden> wrote:
>> On 10/20/2017 10:55 AM, John Arbuckle wrote:
>>> +static inline size_t strnlen(const char *string, size_t max_count)
>>> +{
>>> + size_t count;
>>> + for (count = 0; count < max_count; count++) {
>>> + if (string[count] == '\0') {
>>> + break;
>>> + }
>>> + }
>>> + return count;
>>
>> Not to nitpick, but
>>
>> const char *p = memchr(string, 0, max_count);
>> return p ? max_count : p - string;
>
> Am I misreading that, or do you have the ?: arms the wrong way
> around there?
>
> thanks
> -- PMM
Yes. It should read:
return p ? p - string : max_count;
Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it, Peter Maydell, 2017/10/22
- Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it,
Programmingkid <=