Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-24 Thread David Gibson
On Tue, Oct 24, 2017 at 12:16:47AM -0400, Programmingkid wrote: > > > On Oct 22, 2017, at 1:33 AM, David Gibson > > wrote: > > > > On Fri, Oct 20, 2017 at 04:44:58PM -0700, Richard Henderson wrote: > >> On 10/20/2017 10:55 AM, John Arbuckle wrote: > >>> +static inline size_t strnlen(const char

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-23 Thread Programmingkid
> On Oct 22, 2017, at 1:33 AM, David Gibson wrote: > > On Fri, Oct 20, 2017 at 04:44:58PM -0700, Richard Henderson 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;

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-22 Thread Programmingkid
> On Oct 22, 2017, at 3:06 PM, Ian Lepore wrote: > > On Sun, 2017-10-22 at 10:41 -0400, Programmingkid wrote: >>> >>> On Oct 22, 2017, at 1:33 AM, David Gibson wrote: >>> >>> On Fri, Oct 20, 2017 at 04:44:58PM -0700, Richard Henderson wrote: On 10/20/2017 10:55 AM, John Arbuckle wr

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-22 Thread Ian Lepore
On Sun, 2017-10-22 at 10:41 -0400, Programmingkid wrote: > > > > On Oct 22, 2017, at 1:33 AM, David Gibson wrote: > > > > On Fri, Oct 20, 2017 at 04:44:58PM -0700, Richard Henderson wrote: > > > > > > On 10/20/2017 10:55 AM, John Arbuckle wrote: > > > > > > > > +static inline size_t strnlen(co

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-22 Thread John Reiser
... this one is even smaller. Plus it uses the familiar strlen() function: size_t strnlen(const char *string, size_t max_count) { return strlen(string) < max_count ? strlen(string) : max_count; } Please do not use that implementation. The major goal of strnlen is to avoid looking beyond

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-22 Thread Programmingkid
> On Oct 22, 2017, at 1:33 AM, David Gibson wrote: > > On Fri, Oct 20, 2017 at 04:44:58PM -0700, Richard Henderson 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;

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-22 Thread Programmingkid
> On Oct 22, 2017, at 9:37 AM, Peter Maydell wrote: > > On 21 October 2017 at 00:44, Richard Henderson > 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 <

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-22 Thread Peter Maydell
On 21 October 2017 at 00:44, Richard Henderson 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') { >>

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-22 Thread David Gibson
On Fri, Oct 20, 2017 at 04:44:58PM -0700, Richard Henderson 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[coun

Re: [Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-20 Thread Richard Henderson
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;

[Qemu-devel] [libfdt][PATCH v2] implement strnlen for systems that need it

2017-10-20 Thread John Arbuckle
Prior the Mac OS 10.7, the function strnlen() was not available. This patch implements strnlen() on Mac OS X versions that are below 10.7. Signed-off-by: John Arbuckle --- v2 changes: - Simplified the code to make it static inline'ed - Changed the type of count to size_t libfdt/libfdt_env.h | 2