libosmocore[master]: utils: add osmo_strscpy() macro to use sizeof(dst)

Neels Hofmeyr gerrit-no-reply at
Thu Jan 19 17:06:15 UTC 2017

Patch Set 5:

> yes but the array and sizeof are next to each other.

which makes sense, right? '...sizeof(a...'


interesting :)
we depend on GNU-C anyway, do we?

 > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 > with
 > #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
 > and
 > #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))

With this (slightly bulky) stuff in there, are you saying that osmo_strscpy() would be a good name after all?
Or maybe osmo_strbcpy() for "buffer"...

others have also used strzcpy and strbcpy names, but b meaning padding with "blank" (space?) and z meaning NUL, as it seems...
(whoever those people are)

so I guess osmo_strcpy_sizeof() is still most clear. Single letters are so ambiguous.

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie973fc51835066540eba7ed2946ddf33a268b022
Gerrit-PatchSet: 5
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Holger Freyther <holger at>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at>
Gerrit-HasComments: No

More information about the gerrit-log mailing list