[CRIU] [PATCH 1/2] test: Add unlink_dir test

Cyrill Gorcunov gorcunov at gmail.com
Fri Feb 8 13:01:13 MSK 2019


On Fri, Feb 08, 2019 at 11:59:20AM +0300, Pavel Tikhomirov wrote:
>      +
>      +       len = snprintf(path_dir1, sizeof(path_dir1), "%s/%s", dirname,
>      "gd1");
>      +       if (len == sizeof(path_dir1)) path_dir1[len-1] = '\0';
> 
>    Expression above is strange as snprintf always prints terminating null
>    byte, even if it needs to truncate the output. In other code we either
>    ignore the return of snprintf assuming that we can't have truncation or do
>    check error like: if (len >= sizeof(path_dir1)) return -1;

It is for warnings suppression nothing else. Strictly speaking we might
need to check for negative value rather but since it is path-max limit
i don't expect here any errors at all, just to placate gcc.


More information about the CRIU mailing list