[PATCH 1/8] Remove strlcat(), strlcpy(), strsep(), readdir_r()
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Oct 18 13:00:07 UTC 2018
These functions are provided by Newlib since 2002.
Update #3409.
---
cpukit/Makefile.am | 4 --
cpukit/configure.ac | 7 +--
cpukit/libcsupport/src/readdir_r.c | 35 ---------------
cpukit/libcsupport/src/strlcat.c | 47 --------------------
cpukit/libcsupport/src/strlcpy.c | 49 ---------------------
cpukit/libnetworking/libc/strsep.c | 88 --------------------------------------
6 files changed, 2 insertions(+), 228 deletions(-)
delete mode 100644 cpukit/libcsupport/src/readdir_r.c
delete mode 100644 cpukit/libcsupport/src/strlcat.c
delete mode 100644 cpukit/libcsupport/src/strlcpy.c
delete mode 100644 cpukit/libnetworking/libc/strsep.c
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 6d52eed7d6..7a9ba9599b 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -202,7 +202,6 @@ librtemscpu_a_SOURCES += libcsupport/src/privateenv.c
librtemscpu_a_SOURCES += libcsupport/src/putk.c
librtemscpu_a_SOURCES += libcsupport/src/pwdgrp.c
librtemscpu_a_SOURCES += libcsupport/src/read.c
-librtemscpu_a_SOURCES += libcsupport/src/readdir_r.c
librtemscpu_a_SOURCES += libcsupport/src/readlink.c
librtemscpu_a_SOURCES += libcsupport/src/readv.c
librtemscpu_a_SOURCES += libcsupport/src/realloc.c
@@ -227,8 +226,6 @@ librtemscpu_a_SOURCES += libcsupport/src/setsid.c
librtemscpu_a_SOURCES += libcsupport/src/setuid.c
librtemscpu_a_SOURCES += libcsupport/src/stat.c
librtemscpu_a_SOURCES += libcsupport/src/statvfs.c
-librtemscpu_a_SOURCES += libcsupport/src/strlcat.c
-librtemscpu_a_SOURCES += libcsupport/src/strlcpy.c
librtemscpu_a_SOURCES += libcsupport/src/sup_fs_check_permissions.c
librtemscpu_a_SOURCES += libcsupport/src/sup_fs_deviceio.c
librtemscpu_a_SOURCES += libcsupport/src/sup_fs_eval_path.c
@@ -1246,7 +1243,6 @@ librtemscpu_a_SOURCES += libnetworking/libc/res_send.c
librtemscpu_a_SOURCES += libnetworking/libc/res_stubs.c
librtemscpu_a_SOURCES += libnetworking/libc/res_update.c
librtemscpu_a_SOURCES += libnetworking/libc/send.c
-librtemscpu_a_SOURCES += libnetworking/libc/strsep.c
librtemscpu_a_SOURCES += libnetworking/lib/getprotoby.c
librtemscpu_a_SOURCES += libnetworking/lib/rtems_bsdnet_ntp.c
librtemscpu_a_SOURCES += libnetworking/lib/syslog.c
diff --git a/cpukit/configure.ac b/cpukit/configure.ac
index 2c5e4a1f82..18bebf9412 100644
--- a/cpukit/configure.ac
+++ b/cpukit/configure.ac
@@ -58,7 +58,7 @@ RTEMS_CHECK_NEWLIB
# BSD-isms, used throughout the sources
# Not really used by this configure script
# FIXME: They should be eliminated if possible.
-AC_CHECK_FUNCS([strsep strcasecmp snprintf])
+AC_CHECK_FUNCS([strcasecmp snprintf])
AC_CHECK_FUNCS([strdup strndup strncasecmp])
AC_CHECK_FUNCS([bcopy bcmp])
AC_CHECK_FUNCS([isascii fileno])
@@ -66,7 +66,7 @@ AC_CHECK_FUNCS([isascii fileno])
# <FIXME>
# Check for functions supplied by newlib >= 1.17.0
# Newlib's posix/ directory
-AC_CHECK_FUNCS([readdir_r isatty])
+AC_CHECK_FUNCS([isatty])
AC_CHECK_FUNCS([creat \
opendir closedir readdir rewinddir scandir seekdir \
sleep \
@@ -374,9 +374,6 @@ AC_CHECK_DECLS([LONG_BIT],,,[#include <limits.h>])
AC_CHECK_DECLS([sbrk],,,[#include <unistd.h>])
AC_CHECK_DECLS([rcmd],,,[#include <unistd.h>])
-## Check if libc provides BSD's strlcpy/strlcat
-AC_CHECK_FUNCS(strlcpy strlcat)
-
## Check if libc provides decl of utime
## FIXME: utime has been deprecated in SUSv4.
## and is likely to be removed in future versions.
diff --git a/cpukit/libcsupport/src/readdir_r.c b/cpukit/libcsupport/src/readdir_r.c
deleted file mode 100644
index 0347f25d8b..0000000000
--- a/cpukit/libcsupport/src/readdir_r.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * @file
- *
- * @brief Read a Directory
- * @ingroup libcsupport
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifndef HAVE_READDIR_R
-
-#include <sys/types.h>
-#include <dirent.h>
-#include <errno.h>
-#include <stdio.h>
-
-/**
- * The RTEMS version of readdir is already thread-safe.
- * This routine is reentrant version of readdir().
- */
-int readdir_r(
- DIR *__restrict dirp,
- struct dirent *__restrict entry,
- struct dirent **__restrict result
-)
-{
- *result = readdir(dirp);
- if (*result)
- *entry = **result;
- return *result ? 0 : errno;
-}
-
-#endif
diff --git a/cpukit/libcsupport/src/strlcat.c b/cpukit/libcsupport/src/strlcat.c
deleted file mode 100644
index 6ca17b9d40..0000000000
--- a/cpukit/libcsupport/src/strlcat.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * @file
- *
- * @brief Concatenate a Strings
- * @ingroup libcsupport
- */
-
-/*
- * Copyright (c) 1999 The Australian National University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Australian National University. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#ifndef HAVE_STRLCAT
-
-/**
- * like strcat/strncat, doesn't overflow destination buffer,
- * always leaves destination null-terminated (for len > 0).
- */
-size_t
-strlcat(
- char *dest,
- const char *src,
- size_t len )
-{
- size_t dlen = strlen(dest);
-
- return dlen + strlcpy(dest + dlen, src, (len > dlen? len - dlen: 0));
-}
-#endif
diff --git a/cpukit/libcsupport/src/strlcpy.c b/cpukit/libcsupport/src/strlcpy.c
deleted file mode 100644
index 2773e877cb..0000000000
--- a/cpukit/libcsupport/src/strlcpy.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * utils.c - various utility functions used in pppd.
- *
- * Copyright (c) 1999 The Australian National University.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the Australian National University. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>
-
-#ifndef HAVE_STRLCPY
-/*
- * strlcpy - like strcpy/strncpy, doesn't overflow destination buffer,
- * always leaves destination null-terminated (for len > 0).
- */
-size_t
-strlcpy(dest, src, len)
- char *dest;
- const char *src;
- size_t len;
-{
- size_t ret = strlen(src);
-
- if (len != 0) {
- if (ret < len)
- strcpy(dest, src);
- else {
- strncpy(dest, src, len - 1);
- dest[len-1] = 0;
- }
- }
- return ret;
-}
-#endif
diff --git a/cpukit/libnetworking/libc/strsep.c b/cpukit/libnetworking/libc/strsep.c
deleted file mode 100644
index e7b52a9cbf..0000000000
--- a/cpukit/libnetworking/libc/strsep.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#include <machine/rtems-bsd-user-space.h>
-
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#if !HAVE_STRSEP
-
-#include <string.h>
-#include <stdio.h>
-
-/*
- * Get next token from string *stringp, where tokens are possibly-empty
- * strings separated by characters from delim.
- *
- * Writes NULs into the string at *stringp to end tokens.
- * delim need not remain constant from call to call.
- * On return, *stringp points past the last NUL written (if there might
- * be further tokens), or is NULL (if there are definitely no more tokens).
- *
- * If *stringp is NULL, strsep returns NULL.
- *
- * PUBLIC: #ifndef HAVE_STRSEP
- * PUBLIC: char *strsep __P((char **, const char *));
- * PUBLIC: #endif
- */
-char *
-strsep(stringp, delim)
- register char **stringp;
- register const char *delim;
-{
- register char *s;
- register const char *spanp;
- register int c, sc;
- char *tok;
-
- if ((s = *stringp) == NULL)
- return (NULL);
- for (tok = s;;) {
- c = *s++;
- spanp = delim;
- do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
- s = NULL;
- else
- s[-1] = 0;
- *stringp = s;
- return (tok);
- }
- } while (sc != 0);
- }
- /* NOTREACHED */
-}
-#endif
--
2.16.4
More information about the devel
mailing list