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

Pavel Tikhomirov snorcht at gmail.com
Fri Feb 8 13:24:27 MSK 2019


пт, 8 февр. 2019 г. в 13:01, Cyrill Gorcunov <gorcunov at gmail.com>:

> 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.
>

FMPOV actual overflow check is better here, it is what gcc really wants
from us by these warnings.

Except that, Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20190208/4566167f/attachment-0001.html>


More information about the CRIU mailing list