1From 66b06e03fc25a168e06c7af5ccccc3162ddbf92a Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 13 Nov 2023 17:18:55 -0800
4Subject: [PATCH] beep-library: Make it compatible with < c99
5
6Upstream-Status: Pending
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8---
9 beep-library.c | 9 +++++----
10 1 file changed, 5 insertions(+), 4 deletions(-)
11
12--- a/beep-library.c
13+++ b/beep-library.c
14@@ -44,7 +44,7 @@
15 int open_checked_char_device(const char *const device_name)
16 {
17     struct stat sb;
18-
19+    int fd = -1;
20     if (-1 == stat(device_name, &sb)) {
21         LOG_VERBOSE("could not stat(2) %s: %s",
22                     device_name, strerror(errno));
23@@ -57,7 +57,7 @@ int open_checked_char_device(const char
24         return -1;
25     }
26
27-    const int fd = open(device_name, O_WRONLY);
28+    fd = open(device_name, O_WRONLY);
29     if (fd == -1) {
30         LOG_VERBOSE("could not open(2) %s: %s",
31                     device_name, strerror(errno));
32@@ -90,6 +90,7 @@ void safe_error_exit(const char *const m
33 {
34     const int saved_errno = errno;
35     char strerr_buf[128];
36+    size_t errlen, msglen;
37     const int ret = strerror_r(saved_errno, strerr_buf, sizeof(strerr_buf));
38     if (ret != 0) {
39         if (write(STDERR_FILENO, "strerror_r error\n",
40@@ -98,14 +99,14 @@ void safe_error_exit(const char *const m
41         }
42         _exit(EXIT_FAILURE);
43     }
44-    const size_t msglen = strlen(msg);
45+    msglen = strlen(msg);
46     if (write(STDERR_FILENO, msg, msglen)) {
47         /* ignore all write errors */
48     }
49     if (write(STDERR_FILENO, ": ", 2)) {
50         /* ignore all write errors */
51     }
52-    const size_t errlen = strlen(strerr_buf);
53+    errlen = strlen(strerr_buf);
54     if (write(STDERR_FILENO, strerr_buf, errlen)) {
55         /* ignore all write errors */
56     }
57--- a/GNUmakefile
58+++ b/GNUmakefile
59@@ -155,7 +155,6 @@ $(eval $(call CHECK_CFLAGS,common_CFLAGS
60 $(eval $(call CHECK_CFLAGS,common_CFLAGS,-Wall))
61 $(eval $(call CHECK_CFLAGS,common_CFLAGS,-Wextra))
62 $(eval $(call CHECK_CFLAGS,common_CFLAGS,-Weverything))
63-$(eval $(call CHECK_CFLAGS,common_CFLAGS,-Werror))
64 $(eval $(call CHECK_CFLAGS,common_CFLAGS,-Wno-padded))
65 $(eval $(call CHECK_CFLAGS,common_CFLAGS,-Werror=format-security))
66 $(eval $(call CHECK_CFLAGS,common_CFLAGS,-Wno-disabled-macro-expansion))
67@@ -169,11 +168,6 @@ $(eval $(call CHECK_CFLAGS,CFLAGS,-fanal
68 $(eval $(call CHECK_CFLAGS,CFLAGS,-fstack-protector-strong))
69 $(eval $(call CHECK_CFLAGS,CFLAGS,-fstack-clash-protection))
70 $(eval $(call CHECK_CFLAGS,CFLAGS,-fcf-protection))
71-$(eval $(call CHECK_CFLAGS,CFLAGS,-fsanitize=undefined))
72-
73-
74-CFLAGS += -save-temps=obj
75-
76
77 $(info # common_CFLAGS=$(common_CFLAGS))
78 $(info # CFLAGS=$(CFLAGS))
79