diff options
| -rw-r--r-- | util/dell-flash-unlock/Makefile | 2 | ||||
| -rw-r--r-- | util/dell-flash-unlock/dell_flash_unlock.c | 18 | ||||
| -rw-r--r-- | util/nvmutil/Makefile | 2 | ||||
| -rw-r--r-- | util/nvmutil/nvmutil.c | 2 | ||||
| -rw-r--r-- | util/spkmodem_recv/Makefile | 2 | ||||
| -rw-r--r-- | util/spkmodem_recv/spkmodem-recv.c | 17 |
6 files changed, 23 insertions, 20 deletions
diff --git a/util/dell-flash-unlock/Makefile b/util/dell-flash-unlock/Makefile index 8528c10e..7bb7e1b3 100644 --- a/util/dell-flash-unlock/Makefile +++ b/util/dell-flash-unlock/Makefile @@ -2,7 +2,7 @@ # SPDX-FileCopyrightText: 2023 Nicholas Chin CC=cc -CFLAGS=-Wall -Wextra -Werror -O2 -pedantic +CFLAGS=-Wall -Wextra -O2 SRCS=dell_flash_unlock.c accessors.c all: $(SRCS) accessors.h diff --git a/util/dell-flash-unlock/dell_flash_unlock.c b/util/dell-flash-unlock/dell_flash_unlock.c index d59f5d5b..64fc6daf 100644 --- a/util/dell-flash-unlock/dell_flash_unlock.c +++ b/util/dell-flash-unlock/dell_flash_unlock.c @@ -47,9 +47,9 @@ main(int argc, char *argv[]) (void)argv; if (sys_iopl(3) == -1) - err(errno, "Could not access IO ports"); + err(EXIT_FAILURE, "Could not access IO ports"); if ((devmemfd = open("/dev/mem", O_RDONLY)) == -1) - err(errno, "/dev/mem"); + err(EXIT_FAILURE, "/dev/mem"); /* Read RCBA and PMBASE from the LPC config registers */ long int rcba = pci_read_32(LPC_DEV, 0xf0) & 0xffffc000; @@ -59,11 +59,11 @@ main(int argc, char *argv[]) rcba_mmio = mmap(0, RCBA_MMIO_LEN, PROT_READ, MAP_SHARED, devmemfd, rcba); if (rcba_mmio == MAP_FAILED) - err(errno, "Could not map RCBA"); + err(EXIT_FAILURE, "Could not map RCBA"); if (get_fdo_status() == 1) { /* Descriptor not overridden */ if (check_lpc_decode() == -1) - err(errno = ECANCELED, "Can't forward I/O to LPC"); + err(EXIT_FAILURE, "Can't forward I/O to LPC"); printf("Sending FDO override command to EC:\n"); ec_set_fdo(); @@ -80,7 +80,8 @@ main(int argc, char *argv[]) "to enable SMIs.\n (shutdown is buggy when " "SMIs are disabled)\n"); } else { - err(errno = ECANCELED, "Could not disable SMIs!"); + errno = EIO; + err(EXIT_FAILURE, "Could not disable SMIs!"); } } else { /* SMI locks not in place or bypassed */ if (get_gbl_smi_en()) { @@ -97,7 +98,7 @@ main(int argc, char *argv[]) } } sys_iopl(0); - return errno; + return EXIT_SUCCESS; } int @@ -137,6 +138,7 @@ check_lpc_decode(void) pci_write_32(LPC_DEV, 0x84 + 4 * gen_dec_free, 0x911); return 0; } else { + errno = EIO; return -1; } } @@ -165,7 +167,7 @@ send_ec_cmd(uint8_t cmd) sys_outb(EC_INDEX, 0); sys_outb(EC_DATA, cmd); if (wait_ec() == -1) - err(errno = ECANCELED, "Timeout while waiting for EC!"); + err(EXIT_FAILURE, "Timeout while waiting for EC!"); } int @@ -179,6 +181,8 @@ wait_ec(void) timeout--; usleep(1000); } while (busy && timeout > 0); + if (timeout <= 0) + errno = EIO; return timeout > 0 ? 0 : -1; } diff --git a/util/nvmutil/Makefile b/util/nvmutil/Makefile index 7c7411f9..e8350203 100644 --- a/util/nvmutil/Makefile +++ b/util/nvmutil/Makefile @@ -3,7 +3,7 @@ # SPDX-FileCopyrightText: 2023 Riku Viitanen <riku.viitanen@protonmail.com> CC?=cc -CFLAGS?=-Os -Wall -Wextra -Werror -pedantic +CFLAGS?=-Os -Wall -Wextra DESTDIR?= PREFIX?=/usr/local INSTALL?=install diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index e76fbc47..1910c974 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -234,7 +234,7 @@ readGbe(void) if (buf == NULL) err(EXIT_FAILURE, "malloc"); - gbe[0] = (size_t) buf; + gbe[0] = (uintptr_t) buf; gbe[1] = gbe[0] + (nf * (do_read[0] & do_read[1])); ssize_t tnr = 0; diff --git a/util/spkmodem_recv/Makefile b/util/spkmodem_recv/Makefile index 3c5dc51f..0132baf8 100644 --- a/util/spkmodem_recv/Makefile +++ b/util/spkmodem_recv/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later CC?=cc -CFLAGS?=-Os -Wall -Wextra -Werror -pedantic +CFLAGS?=-Os -Wall -Wextra DESTDIR?= PREFIX?=/usr/local INSTALL?=install diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index 4467282d..6fcd356f 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -23,7 +23,6 @@ #define FREQ_DATA_MAX 60 #define THRESHOLD 500 -#define ERR() (errno = errno ? errno : ECANCELED) #define reset_char() ascii = 0, ascii_bit = 7 signed short frame[MAX_SAMPLES], pulse[MAX_SAMPLES]; @@ -42,17 +41,17 @@ main(int argc, char *argv[]) int c; #ifdef __OpenBSD__ if (pledge("stdio", NULL) == -1) - err(ERR(), "pledge"); + err(EXIT_FAILURE, "pledge"); #endif while ((c = getopt(argc, argv, "d")) != -1) - if (!(debug = (c == 'd'))) - err(errno = EINVAL, NULL); + if (!(debug = (c == 'd'))) { + errno = EINVAL; + err(EXIT_FAILURE, "%c: Invalid option", c); + } setvbuf(stdout, NULL, _IONBF, 0); while (!feof(stdin)) handle_audio(); - if (errno && debug) - err(errno, "Unhandled error, errno %d", errno); - return errno; + return EXIT_SUCCESS; } void @@ -83,7 +82,7 @@ decode_pulse(void) fread(frame + ringpos, 1, sizeof(frame[0]), stdin); if (ferror(stdin) != 0) - err(ERR(), "Could not read from frame."); + err(EXIT_FAILURE, "Could not read from frame."); if ((pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0)) ++freq_separator; @@ -118,7 +117,7 @@ print_stats(void) { long stdin_pos; if ((stdin_pos = ftell(stdin)) == -1) - err(ERR(), NULL); + err(EXIT_FAILURE, NULL); printf ("%d %d %d @%ld\n", freq_data, freq_separator, FREQ_DATA_THRESHOLD, stdin_pos - sizeof(frame)); } |
