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 i;
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' &&
line[i] != '\n' && line[i] != '\r' &&
line[i] != '\f' && line[i] != '\0')

View File

@ -151,13 +151,13 @@ static inline char *deabs(char *str)
return str + strspn(str, "/");
}
#define strnprintf(buf, buf_size, ...) \
({ \
int __ret_strnprintf; \
__ret_strnprintf = snprintf(buf, buf_size, ##__VA_ARGS__); \
if (__ret_strnprintf < 0 || (size_t)__ret_strnprintf >= buf_size) \
__ret_strnprintf = ret_errno(EIO); \
__ret_strnprintf; \
#define strnprintf(buf, buf_size, ...) \
({ \
int __ret_strnprintf; \
__ret_strnprintf = snprintf(buf, buf_size, ##__VA_ARGS__); \
if (__ret_strnprintf < 0 || (size_t)__ret_strnprintf >= (size_t)buf_size) \
__ret_strnprintf = ret_errno(EIO); \
__ret_strnprintf; \
})
static inline const char *proc_self_fd(int fd)