[LEDE-DEV] [PATCH procd 2/2] upgraded: Check chroot() return value
Matthias Schiffer
mschiffer at universe-factory.net
Sun Jul 16 10:40:43 PDT 2017
On 07/15/2017 09:44 PM, Florian Fainelli wrote:
> Check the chroot() return value, fixes unused return value warnings/errors:
>
> procd-2017-06-22-e5e99c46/upgraded/upgraded.c:78:8: error: ignoring return
> value of 'chroot', declared with attribute warn_unused_result
> [-Werror=unused-result] chroot(".");
>
> Fixes: 056d8ddda8d5 ("upgraded: link dynamically, chroot during exec")
> Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
> ---
LGTM.
Reviewed-by: Matthias Schiffer <mschiffer at universe-factory.net>
> upgraded/upgraded.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c
> index 09c623cf804b..220da7903f92 100644
> --- a/upgraded/upgraded.c
> +++ b/upgraded/upgraded.c
> @@ -78,7 +78,10 @@ int main(int argc, char **argv)
> return 1;
> }
>
> - chroot(".");
> + if (chroot(".") < 0) {
> + fprintf(stderr, "failed to chroot: %s\n", strerror(errno));
> + return 1;
> + }
>
> if (fchdir(fd) == -1) {
> fprintf(stderr, "failed to chdir to prefix directory: %s\n", strerror(errno));
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20170716/dbed9e7d/attachment.sig>
More information about the Lede-dev
mailing list