At some point someone added syntax-checks to fail if old BSD types
where used:
u_char -> unsigned char
u_short -> unsigned short
u_long -> unsigned long
But they forgot to do u_int. Patch 0001 adds one for u_int and patch
0002 removes them.
IIRC Glibc and MinGW define these, so it would work fine in 99% of
places.
Collin
From 90f512bb93d9aa5b9b1c1c38991c0b53283db45d Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 4 May 2024 01:34:39 -0700
Subject: [PATCH 1/2] cfg.mk: Add checks for 'u_int'.
* cfg.mk (sc_unsigned_int): New rule.
(sc_unsigned_short): Correct type in error message.
---
cfg.mk | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/cfg.mk b/cfg.mk
index 9eddbcf2..1be7e6f9 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -82,7 +82,12 @@ sc_unsigned_long:
sc_unsigned_short:
@prohibit=u''_short \
- halt='don'\''t use u''_char; instead use unsigned short' \
+ halt='don'\''t use u''_short; instead use unsigned short' \
+ $(_sc_search_regexp)
+
+sc_unsigned_int:
+ @prohibit=u''_int \
+ halt='don'\''t use u''_int; instead use unsigned int' \
$(_sc_search_regexp)
sc_assignment_in_if:
--
2.44.0
From 8b4b897f32aaa316824b6730dee62671dfb282bd Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 4 May 2024 01:42:20 -0700
Subject: [PATCH 2/2] Fix sc_unsigned_int checks.
* ftpd/ftpd.c (send_data, receive_data): Convert 'u_int' to
'unsigned int'.
* libinetutils/ttymsg.c (inetutils_ttymsg): Likewise.
* libls/extern.h: Likewise.
* libls/print.c (minor, printtype): Likewise.
* libls/stat_flags.c (flags_to_string, string_to_flags): Likewise.
* src/rlogin.c (winsize, get_window_size, getescape): Likewise.
* src/rsh.c (copyargs): Likewise.
---
ftpd/ftpd.c | 6 +++---
libinetutils/ttymsg.c | 2 +-
libls/extern.h | 2 +-
libls/print.c | 4 ++--
libls/stat_flags.c | 4 ++--
src/rlogin.c | 8 ++++----
src/rsh.c | 2 +-
7 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c
index 6df4f50a..d225f191 100644
--- a/ftpd/ftpd.c
+++ b/ftpd/ftpd.c
@@ -1441,14 +1441,14 @@ send_data (FILE *instr, FILE *outstr, off_t blksize)
syslog (LOG_DEBUG, "Starting at position %jd.", curpos);
}
- buf = malloc ((u_int) blksize);
+ buf = malloc ((unsigned int) blksize);
if (buf == NULL)
{
transflag = 0;
perror_reply (451, "Local resource failure: malloc");
return;
}
- while ((cnt = read (filefd, buf, (u_int) blksize)) > 0 &&
+ while ((cnt = read (filefd, buf, (unsigned int) blksize)) > 0 &&
write (netfd, buf, cnt) == cnt)
byte_count += cnt;
@@ -1499,7 +1499,7 @@ receive_data (FILE *instr, FILE *outstr, off_t blksize)
{
case TYPE_I:
case TYPE_L:
- buf = malloc ((u_int) blksize);
+ buf = malloc ((unsigned int) blksize);
if (buf == NULL)
{
transflag = 0;
diff --git a/libinetutils/ttymsg.c b/libinetutils/ttymsg.c
index bf0f2bb3..43471beb 100644
--- a/libinetutils/ttymsg.c
+++ b/libinetutils/ttymsg.c
@@ -180,7 +180,7 @@ inetutils_ttymsg (struct iovec *iov, int iovcnt, char *line, int tmout)
#else
sigsetmask (0);
#endif
- alarm ((u_int) tmout);
+ alarm ((unsigned int) tmout);
fcntl (fd, O_NONBLOCK, &off);
continue;
}
diff --git a/libls/extern.h b/libls/extern.h
index 57a17e83..0fffadb3 100644
--- a/libls/extern.h
+++ b/libls/extern.h
@@ -56,7 +56,7 @@ int revstatcmp (const FTSENT *, const FTSENT *);
int sizecmp (const FTSENT *, const FTSENT *);
int revsizecmp (const FTSENT *, const FTSENT *);
-char *flags_to_string (u_int, char *);
+char *flags_to_string (unsigned int, char *);
int putname (char *);
void printcol (DISPLAY *);
void printacol (DISPLAY *);
diff --git a/libls/print.c b/libls/print.c
index 10b4488f..c4d5afb6 100644
--- a/libls/print.c
+++ b/libls/print.c
@@ -89,7 +89,7 @@
static int printaname (FTSENT *, unsigned long, unsigned long);
static void printlink (FTSENT *);
static void printtime (time_t);
-static int printtype (u_int);
+static int printtype (unsigned int);
static int compute_columns (DISPLAY *, int *);
#define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT)
@@ -356,7 +356,7 @@ printstream (DISPLAY *dp)
}
static int
-printtype (u_int mode)
+printtype (unsigned int mode)
{
switch (mode & S_IFMT)
{
diff --git a/libls/stat_flags.c b/libls/stat_flags.c
index 47028e0b..9ff4bdc1 100644
--- a/libls/stat_flags.c
+++ b/libls/stat_flags.c
@@ -65,7 +65,7 @@
* are set, return the default string.
*/
char *
-flags_to_string (u_int flags, char *def)
+flags_to_string (unsigned int flags, char *def)
{
static char string[128];
char *prefix;
@@ -93,7 +93,7 @@ flags_to_string (u_int flags, char *def)
* to the offending token.
*/
int
-string_to_flags (char **stringp, u_int *setp, u_int *clrp)
+string_to_flags (char **stringp, unsigned int *setp, unsigned int *clrp)
{
if (setp)
*setp = 0;
diff --git a/src/rlogin.c b/src/rlogin.c
index 7516aa4c..46e326b3 100644
--- a/src/rlogin.c
+++ b/src/rlogin.c
@@ -203,7 +203,7 @@ void copytochild (int);
void doit (sigset_t *);
void done (int);
void echo (char);
-u_int getescape (char *);
+unsigned int getescape (char *);
void lostpeer (int);
void mode (int);
void oob (int);
@@ -1455,7 +1455,7 @@ get_window_size (int fd, struct winsize *wp)
}
#endif
-u_int
+unsigned int
getescape (register char *p)
{
long val;
@@ -1463,7 +1463,7 @@ getescape (register char *p)
len = strlen (p);
if (len == 1) /* use any single char, including '\'. */
- return ((u_int) * p);
+ return ((unsigned int) *p);
/* otherwise, \nnn */
if (*p == '\\' && len >= 2 && len <= 4)
@@ -1472,7 +1472,7 @@ getescape (register char *p)
for (;;)
{
if (!*++p)
- return ((u_int) val);
+ return ((unsigned int) val);
if (*p < '0' || *p > '8')
break;
}
diff --git a/src/rsh.c b/src/rsh.c
index 53f73437..7e6dd195 100644
--- a/src/rsh.c
+++ b/src/rsh.c
@@ -830,7 +830,7 @@ copyargs (char **argv)
cc = 0;
for (ap = argv; *ap; ++ap)
cc += strlen (*ap) + 1;
- args = malloc ((u_int) cc);
+ args = malloc ((unsigned int) cc);
if (!args)
error (EXIT_FAILURE, errno, "copyargs");
for (p = args, ap = argv; *ap; ++ap)
--
2.44.0