commit 14fd8749d8cf462851d64a475a328c2fd15d8c05 from: Benjamin Stürz date: Tue May 30 17:30:57 2023 UTC Better error handling Signed-off-by: Benjamin Stürz commit - f3229a3c291039b48614f0d73f5e53352310e902 commit + 14fd8749d8cf462851d64a475a328c2fd15d8c05 blob - e3e92c19f169e0fe08abdb4d1230b4ccc98e5cde blob + 4d7674e9dcc29248f5ba4628ab5c17488c959beb --- ChangeLog.md +++ ChangeLog.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.2.3] - 2023-05-30 +## Changed +- Better error handling + ## [1.2.2] - 2023-05-30 ## Changed - Removed `-Werror` blob - ee42ebb48517e19ad7a85c08d7198be38623ce07 blob + 8613aea670334cca11c0965577db4aecb12cacfd --- Makefile +++ Makefile @@ -2,7 +2,7 @@ # See LICENSE file for copyright and license details. .POSIX: -VERSION = 1.2.2 +VERSION = 1.2.3 PREFIX = /usr/local MANPREFIX = ${PREFIX}/man MY_CFLAGS = -Wall -Wextra -pedantic -std=c99 -DVERSION=\"${VERSION}\" ${CFLAGS} blob - 5a3034039510580aaa16886bd6666d1303af8a98 blob + 9537ce9574efeab9d924b5d6963af5814e503ccd --- lsblk.c +++ lsblk.c @@ -580,6 +580,7 @@ int main (int argc, char *argv[]) int option; int fields = FIELD_DEFAULT; int options = 0; + int ret = 0; if (unveil ("/dev", "r") == -1) err (1, "unveil(/dev)"); @@ -645,6 +646,8 @@ int main (int argc, char *argv[]) *colon = '\0'; if (read_disk (name, &disk) == 0) { disks[num_disks++] = disk; + } else { + ret = 1; } if (colon) @@ -662,12 +665,17 @@ int main (int argc, char *argv[]) } if (read_disk (name, &disk) == 0) { disks[num_disks++] = disk; + } else { + ret = 1; } } } free (names); + if (num_disks == 0) + return ret; + mergesort (disks, num_disks, sizeof *disks, compare_disk); if (!(options & OPT_NOBIO)) { @@ -692,5 +700,5 @@ int main (int argc, char *argv[]) print_disk (&disks[i], fields, options, NULL, &p); } - return 0; + return ret; }