On 28 January 2015 at 12:21, Savolainen, Petri (NSN - FI/Espoo)
<[email protected]> wrote:
>
>
>> -----Original Message-----
>> From: [email protected] [mailto:lng-odp-
>> [email protected]] On Behalf Of ext Ola Liljedahl
>> Sent: Wednesday, January 28, 2015 12:48 PM
>> To: LNG ODP Mailman List
>> Subject: [lng-odp] odp_cpumask.h
>>
>>  * @param str    Output buffer
>>  * @param len    Size of string length (incl. ending zero)
>>  */
>> void odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int len);
>>
>> Why don't we use size_t for the"len" parameter?
>>
>> -- Ola
>
>
> It's an object size, so it can be changed to size_t (similar to e.g. 
> snprintf()).
>
> Packet data len/offsets, buffer sizes, packet/bytes counts etc, should be 
> uintxx_t - but object sizes should be size_t.
>
>
> Answer to: What happens if len < output length? Maybe we copy the snprintf 
> definition (except output also ending zero). Return number chars written 
> (incl. str ending zero), otherwise return number of chars that would have 
> been outputted (return >len and clip output).
This is more complicated to check for and goes against the convention
of returning <0 for errors.
I would prefer my suggestion with returning -(minimum required buffer
size), there's a clear separation between success and error.

And that we add a define with a suggested buffer size which will be
usable when the CPU mask is full (all bits set), this seems to be 128
when using Linux cpu_set_t for the implementation. Of course ODP could
use a smaller max size as well.

>
> -Petri

_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to