string_utils: fix integer comparisons

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2021-09-03 10:14:55 +02:00
parent 02d477ccc6
commit a5e92f5dff
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
2 changed files with 8 additions and 9 deletions

View File

@ -1000,10 +1000,9 @@ char *lxc_trim_whitespace_in_place(char *buffer)
int lxc_is_line_empty(const char *line) int lxc_is_line_empty(const char *line)
{ {
int i;
size_t len = strlen(line); size_t len = strlen(line);
for (i = 0; i < len; i++) for (size_t i = 0; i < len; i++)
if (line[i] != ' ' && line[i] != '\t' && if (line[i] != ' ' && line[i] != '\t' &&
line[i] != '\n' && line[i] != '\r' && line[i] != '\n' && line[i] != '\r' &&
line[i] != '\f' && line[i] != '\0') line[i] != '\f' && line[i] != '\0')

View File

@ -155,7 +155,7 @@ static inline char *deabs(char *str)
({ \ ({ \
int __ret_strnprintf; \ int __ret_strnprintf; \
__ret_strnprintf = snprintf(buf, buf_size, ##__VA_ARGS__); \ __ret_strnprintf = snprintf(buf, buf_size, ##__VA_ARGS__); \
if (__ret_strnprintf < 0 || (size_t)__ret_strnprintf >= buf_size) \ if (__ret_strnprintf < 0 || (size_t)__ret_strnprintf >= (size_t)buf_size) \
__ret_strnprintf = ret_errno(EIO); \ __ret_strnprintf = ret_errno(EIO); \
__ret_strnprintf; \ __ret_strnprintf; \
}) })