cgroup-util: check ferror() first
Also, there's no need to set use errno_or_else(), since fscanf() is documented to set errno on error.
This commit is contained in:
@@ -2141,15 +2141,14 @@ int cg_kernel_controllers(Set **ret) {
|
||||
_cleanup_free_ char *controller = NULL;
|
||||
int enabled = 0;
|
||||
|
||||
errno = 0;
|
||||
if (fscanf(f, "%ms %*i %*i %i", &controller, &enabled) != 2) {
|
||||
|
||||
if (ferror(f))
|
||||
return -errno;
|
||||
|
||||
if (feof(f))
|
||||
break;
|
||||
|
||||
if (ferror(f))
|
||||
return errno_or_else(EIO);
|
||||
|
||||
return -EBADMSG;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user