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.
This commit is contained in:
Luca Weiss 2019-08-07 21:00:12 +02:00 committed by Martijn Braam
parent 9d6a3540ad
commit dfdba5b4a7
No known key found for this signature in database
GPG key ID: C4280ACB000B060F
2 changed files with 5 additions and 4 deletions

View file

@ -1,7 +1,7 @@
# Contributor: Daniele Debernardi <drebrez@gmail.com>
# Maintainer: Daniele Debernardi <drebrez@gmail.com>
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"

View file

@ -4,6 +4,7 @@
*
* Copyright (C) 2019 Daniele Debernardi <drebrez@gmail.com>
*/
#include <errno.h>
#include <linux/reboot.h>
#include <stdio.h>
#include <stdlib.h>
@ -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;