chreipl: make write_str_errno return errno as the name suggests

Make write_str_errno return errno in all error cases, so that it would
be usable in scenarious where open call could fail and we just want to
get an errno, not to exit.

This function is currently only used by chshut in a context where
such a change wouldn't hurt debug ability.

159         if (write_str_errno(argv[2], path))
160                 ERR_EXIT_ERRNO("Could not set \"%s\"", path);

Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Vasily Gorbik
2018-04-05 16:51:48 +02:00
committed by Jan Höppner
parent 4b33d80595
commit 262a827ab4

View File

@@ -129,7 +129,7 @@ int write_str_errno(char *string, char *file)
snprintf(path, sizeof(path), "/sys/firmware/%s", file);
fh = open(path, O_WRONLY);
if (fh < 0)
ERR_EXIT_ERRNO("Could not open \"%s\"", file);
return errno;
if (write(fh, value, strlen(value)) < 0)
return errno;
close(fh);