From: Kamalesh Babulal Date: Mon, 14 Feb 2022 15:11:08 +0000 (-0700) Subject: wrapper: remove false checks for snprintf X-Git-Tag: v3.0~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0a71d0ee9a95936cbdad953284334441abf0f60;p=thirdparty%2Flibcgroup.git wrapper: remove false checks for snprintf LGTM, reported that the negative value checks for snprintf() will always be false. The reason being the snprintf() are used to print into a character buffer, hence chances of stream error or wide characters encoding error are not valid here. Remove the negative return value check across the file done after snprintf(). Reported-by: LGTM Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/wrapper.c b/src/wrapper.c index 3d50c5a7..826ccad5 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -532,7 +532,7 @@ int cgroup_set_value_int64(struct cgroup_controller *controller, ret = snprintf(val->value, sizeof(val->value), "%" PRId64, value); - if (ret >= sizeof(val->value) || ret < 0) + if (ret >= sizeof(val->value)) return ECGINVAL; val->dirty = true; @@ -581,7 +581,7 @@ int cgroup_set_value_uint64(struct cgroup_controller *controller, ret = snprintf(val->value, sizeof(val->value), "%" PRIu64, value); - if (ret >= sizeof(val->value) || ret < 0) + if (ret >= sizeof(val->value)) return ECGINVAL; val->dirty = true; @@ -641,7 +641,7 @@ int cgroup_set_value_bool(struct cgroup_controller *controller, sizeof(val->value), "0"); } - if (ret >= sizeof(val->value) || ret < 0) + if (ret >= sizeof(val->value)) return ECGINVAL; val->dirty = true;