From dfdba5b4a73d5682523914a608c8a6819732b182 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Wed, 7 Aug 2019 21:00:12 +0200 Subject: [PATCH] main/reboot-mode: Fix printing of error (!551) Previously, running reboot-mode as an unprivileged user resulted in Error: No error information without a newline at the end. According to SYSCALL(2), the return value of -1 indicated an error, but the actual error code is stored in errno. --- main/reboot-mode/APKBUILD | 4 ++-- main/reboot-mode/reboot-mode.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/main/reboot-mode/APKBUILD b/main/reboot-mode/APKBUILD index 2b805cb8a..3e7573d63 100644 --- a/main/reboot-mode/APKBUILD +++ b/main/reboot-mode/APKBUILD @@ -1,7 +1,7 @@ # Contributor: Daniele Debernardi # Maintainer: Daniele Debernardi pkgname=reboot-mode -pkgver=0.1 +pkgver=0.2 pkgrel=0 pkgdesc="Reboot the device to a specific mode" url="https://postmarketos.org" @@ -22,4 +22,4 @@ package() { "${pkgdir}/usr/sbin/reboot-mode" } -sha512sums="37d282608f30b1b8fa4f7501a8afcaa81902c9dfaee0c4c92ab05028e3a99a69c601dc7fce6ab06582db044b6fd0f5bffabe9d6064af9e670266978d66fe2515 reboot-mode.c" +sha512sums="a0cd4097d24fb6c66edce60558942d18ccf45925013013e5af5437471b1a855abe12857deb45b5f970b04e8b9dba99177b9080fff584fbd16262f0a7aabbf4b1 reboot-mode.c" diff --git a/main/reboot-mode/reboot-mode.c b/main/reboot-mode/reboot-mode.c index 36561d9b3..5df5228c2 100644 --- a/main/reboot-mode/reboot-mode.c +++ b/main/reboot-mode/reboot-mode.c @@ -4,6 +4,7 @@ * * Copyright (C) 2019 Daniele Debernardi */ +#include #include #include #include @@ -42,8 +43,8 @@ int main(int argc, char **argv) int ret; ret = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, argv[1]); - if (ret) { - printf("Error: %s", strerror(ret)); + if (ret < 0) { + printf("Error: %s\n", strerror(errno)); } return ret;