Do you have any specific examples? Just picking one randomly and the first error checking code I saw looked like this:
if (ctx->main_conf == NULL) {
return NGX_CONF_ERROR;
} if (ctx->main_conf == NULL) {
return NGX_CONF_ERROR;
} /* No MIN_SIZEOF here - we absolutely *must not* truncate the
* username (XXX - so check for trunc!) */
strlcpy(li->username, pw->pw_name, sizeof(li->username));Basically the remark was that the comment went from discussing error handling, to the (much) broader scope of 'C and C++ done "right"', and as an example 5 complete, large open source projects were dumped for us to find the examples ourselves.
if (strlcpy(li->username, pw->pw_name, sizeof(li->username)) >=
sizeof(li->username)) {
error("%s: username too long (%lu > max %lu)", __func__,
(unsigned long)strlen(pw->pw_name),
(unsigned long)sizeof(li->username) - 1);
return NULL;
} rv = strlcpy(dst, src, sizeof(dst));
check(rv == strlen(dst), "Error, src string truncated");
Or perhaps more clear: strlcpy(dst, src, sizeof(dst));
check(strlen(src) == strlen(dst), "Error, src string truncated");