[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix minor portability issues including ISO C 23 prototypes.
From: |
Collin Funk |
Subject: |
[PATCH] Fix minor portability issues including ISO C 23 prototypes. |
Date: |
Tue, 13 Feb 2024 21:26:07 -0800 |
User-agent: |
Mozilla Thunderbird |
Hi, I noticed some compiler warnings that might be worth fixing. I
wasn't sure if patches should have ChangeLog entries so I left it
alone and tried to make it easy to copy paste for you. Feel free to
use or ignore changes as you see fit.
Thanks,
Collin
* lib/malloc/malloc.c (botch): Add correct prototype so declaration is
compatible with C23.
* lib/malloc/table.h (mregister_describe_mem): Add correct prototype
so declaration is compatible with C23.
* lib/sh/getenv.c (getenv, putenv, setenv, unsetenv): Don't assume
that NULL is equivalent to 0 and just use the macro itself.
* lib/sh/strlcpy.c (strlcpy): Remove duplicate const qualifier.
diff from commit fbc7d97de6c6f3dedb34f49f89a628a99ef6ddf5 on devel:
---
lib/malloc/malloc.c | 3 ++-
lib/malloc/table.h | 2 +-
lib/sh/getenv.c | 10 +++++-----
lib/sh/strlcpy.c | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c
index f829d395..9674f4d0 100644
--- a/lib/malloc/malloc.c
+++ b/lib/malloc/malloc.c
@@ -322,7 +322,8 @@ static PTR_T internal_valloc (size_t, const char *, int,
int);
static PTR_T internal_remap (PTR_T, size_t, int, int);
#if defined (botch)
-extern void botch ();
+/* XXX - set to `programming_error' by Makefile. */
+extern void botch (const char *, ...);
#else
static void botch (const char *, const char *, int);
#endif
diff --git a/lib/malloc/table.h b/lib/malloc/table.h
index e7803762..f8f74639 100644
--- a/lib/malloc/table.h
+++ b/lib/malloc/table.h
@@ -60,7 +60,7 @@ typedef struct mr_table {
extern mr_table_t *mr_table_entry (PTR_T);
extern void mregister_alloc (const char *, PTR_T, size_t, const char *, int);
extern void mregister_free (PTR_T, int, const char *, int);
-extern void mregister_describe_mem ();
+extern void mregister_describe_mem (PTR_T, FILE *);
extern void mregister_dump_table (void);
extern void mregister_table_init (void);
diff --git a/lib/sh/getenv.c b/lib/sh/getenv.c
index 6917f075..f19d2c69 100644
--- a/lib/sh/getenv.c
+++ b/lib/sh/getenv.c
@@ -51,7 +51,7 @@ getenv (const char *name)
{
SHELL_VAR *var;
- if (name == 0 || *name == '\0')
+ if (name == NULL || *name == '\0')
return ((char *)NULL);
var = find_tempenv_variable ((char *)name);
@@ -103,7 +103,7 @@ putenv (char *str)
char *name, *value;
int offset;
- if (str == 0 || *str == '\0')
+ if (str == NULL || *str == '\0')
{
errno = EINVAL;
return -1;
@@ -148,13 +148,13 @@ setenv (const char *name, const char *value, int rewrite)
SHELL_VAR *var;
char *v;
- if (name == 0 || *name == '\0' || strchr (name, '=') != 0)
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
{
errno = EINVAL;
return -1;
}
- var = 0;
+ var = NULL;
v = (char *)value; /* some compilers need explicit cast */
/* XXX - should we worry about readonly here? */
if (rewrite == 0)
@@ -186,7 +186,7 @@ _setenv (const char *name, const char *value, int rewrite)
int
unsetenv (const char *name)
{
- if (name == 0 || *name == '\0' || strchr (name, '=') != 0)
+ if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
{
errno = EINVAL;
return (-1);
diff --git a/lib/sh/strlcpy.c b/lib/sh/strlcpy.c
index 787e4c36..ae30c2ee 100644
--- a/lib/sh/strlcpy.c
+++ b/lib/sh/strlcpy.c
@@ -23,7 +23,7 @@
#include <bashansi.h>
size_t
-strlcpy(char *dest, const const char *src, size_t size)
+strlcpy (char *dest, const char *src, size_t size)
{
size_t ret;
--
2.39.2
- [PATCH] Fix minor portability issues including ISO C 23 prototypes.,
Collin Funk <=