> -----Original Message-----
> From: ext Ola Liljedahl [mailto:ola.liljed...@linaro.org]
> Sent: Wednesday, February 04, 2015 2:03 PM
> To: Savolainen, Petri (NSN - FI/Espoo)
> Cc: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [PATCHv4 01/18] api: odp_cpumask.h:
> odp_cpumask_to_str() return chars written or error
> 
> On 4 February 2015 at 09:38, Savolainen, Petri (NSN - FI/Espoo)
> <petri.savolai...@nsn.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp-
> >> boun...@lists.linaro.org] On Behalf Of ext Savolainen, Petri (NSN -
> >> FI/Espoo)
> >> Sent: Wednesday, February 04, 2015 10:31 AM
> >> To: ext Ola Liljedahl
> >> Cc: lng-odp@lists.linaro.org
> >> Subject: Re: [lng-odp] [PATCHv4 01/18] api: odp_cpumask.h:
> >> odp_cpumask_to_str() return chars written or error
> >>
> >> > >> diff --git a/include/odp/api/cpumask.h b/include/odp/api/cpumask.h
> >> > >> index 7482899..65969c3 100644
> >> > >> --- a/include/odp/api/cpumask.h
> >> > >> +++ b/include/odp/api/cpumask.h
> >> > >> @@ -18,12 +18,20 @@
> >> > >>  extern "C" {
> >> > >>  #endif
> >> > >>
> >> > >> +#include <sys/types.h>
> >> > >> +#include <odp/config.h>
> >> > >> +
> >> > >>  /** @addtogroup odp_scheduler
> >> > >>   *  CPU mask operations.
> >> > >>   *  @{
> >> > >>   */
> >> > >>
> >> > >> - /**
> >> > >> +/**
> >> > >> + * @def ODP_CPUMASK_BUFSIZE
> >> > >> + * Minimum size of output buffer for odp_cpumask_to_str()
> >> > >> + */
> >> > >
> >> > > ODP_CPUMASK_STRLEN is better. Better to use term string when it's a
> >> > character string.
> >>
> >> This one is missing from v5.
> >>
> >> Better name it STRLEN when it used for _to_str() and _from_str()
> function
> >> calls.
> >>
> >> char mask_str[ODP_CPUMASK_STRLEN];
> >> memset(mask_str, 0, sizeof(mask_str));
> >> odp_cpumask_to_str(mask, mask_str, sizeof(mask_str));
> >> odp_cpumask_from_str(mask, mask_str);
> >>
> >>
> >> -Petri
> >
> >
> > Or ODP_CPUMASK_STRLEN_MAX or ODP_CPUMASK_STR_MAX_CHARS ...
> >
> > The point is that, it's defining the max number of chars (not bytes)
> needed for the string output
> In C, "byte" means storage unit. A "char" is defined to take one
> storage unit (sizeof(char)==1).


Yeah, I know. But in common language byte refers to 8 bits. Normally it is like 
that and lot's of SW would break if it's not. We have both used chips with 16 
bit chars in the past.

My point is that "str" highlights to the user that it's a character string, and 
not a byte (==> 8-bit) buffer.

int8_t buf[BUF_SIZE]; // wrong, although it compiles due to "typedef char 
int8_t"

vs

char str[STR_SIZE];


-Petri


> See e.g. C - A Reference Manual; Harbison, Steele Jr. (chapter 6.1.1
> in the 4th edition)
> or http://c0x.coding-guidelines.com/6.5.3.4.html
> 
> So for an array of char (the odp_cpumask_to_str() uses "char *" to
> reference this array), there is no practical nor semantic difference
> between number of chars or number of bytes. We could have added some
> more words to the description (e.g. "size of output buffer in chars")
> but I think this would be redundant and potentially confusing (as the
> size in chars is the default and the output buffer is specified as an
> array of char).
> 
> In a case where the output buffer is of some non-char type, it makes
> sense to specify what type is used for the size if this is not
> otherwise obvious from the description.
> 
> 
> 
> > - and it cannot be mixed with the odp_cpumask_t (buffer) size.
> >
> >
> > -Petri
> >
> >
> >
> >
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to