summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Monjalon <thomas.monjalon@6wind.com>2014-09-26 16:13:37 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-09-29 15:04:55 +0200
commit3185322809c1ae1b46192c5eb1447b11527720c3 (patch)
tree78d009745b6560148a7edf821d2ee83330f10b3f
parentaccf99308bacb2131ecb1880dd06d41dfafc8f3f (diff)
downloaddpdk-3185322809c1ae1b46192c5eb1447b11527720c3.zip
dpdk-3185322809c1ae1b46192c5eb1447b11527720c3.tar.gz
dpdk-3185322809c1ae1b46192c5eb1447b11527720c3.tar.xz
eal: remove rte_snprintf
The function rte_snprintf() was deprecated in version 1.7.0 (commit 6f41fe75e2dd). It's now totally removed. Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com> Acked-by: Neil Horman <nhorman@tuxdriver.com>
-rw-r--r--app/test/Makefile7
-rw-r--r--app/test/test_string_fns.c136
-rw-r--r--lib/librte_eal/common/eal_common_string_fns.c28
-rw-r--r--lib/librte_eal/common/include/rte_string_fns.h24
-rw-r--r--lib/librte_eal/common/include/rte_warnings.h4
5 files changed, 1 insertions, 198 deletions
diff --git a/app/test/Makefile b/app/test/Makefile
index 37a3772..6af6d76 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -137,13 +137,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_KVARGS) += test_kvargs.c
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
-# Allow use of deprecated rte_snprintf in test_string_fns.c
-ifeq ($(CC), icc)
-CFLAGS_test_string_fns.o += -Wd1478
-else
-CFLAGS_test_string_fns.o += -Wno-deprecated-declarations
-endif
-
# Disable warnings of deprecated-declarations in test_kni.c
ifeq ($(CC), icc)
CFLAGS_test_kni.o += -wd1478
diff --git a/app/test/test_string_fns.c b/app/test/test_string_fns.c
index 29bfe5b..39e6a9d 100644
--- a/app/test/test_string_fns.c
+++ b/app/test/test_string_fns.c
@@ -49,139 +49,6 @@
#define DATA_BYTE 'a'
static int
-test_rte_snprintf(void)
-{
- /* =================================================
- * First test with a string that will fit in buffer
- * =================================================*/
- do {
- int retval;
- const char source[] = "This is a string that will fit in buffer";
- char buf[sizeof(source)+2]; /* make buffer big enough to fit string */
-
- /* initialise buffer with characters so it can contain no nulls */
- memset(buf, DATA_BYTE, sizeof(buf));
-
- /* run rte_snprintf and check results */
- retval = rte_snprintf(buf, sizeof(buf), "%s", source);
- if (retval != sizeof(source) - 1) {
- LOG("Error, retval = %d, expected = %u\n",
- retval, (unsigned)sizeof(source));
- return -1;
- }
- if (buf[retval] != '\0') {
- LOG("Error, resultant is not null-terminated\n");
- return -1;
- }
- if (memcmp(source, buf, sizeof(source)-1) != 0){
- LOG("Error, corrupt data in buffer\n");
- return -1;
- }
- } while (0);
-
- do {
- /* =================================================
- * Test with a string that will get truncated
- * =================================================*/
- int retval;
- const char source[] = "This is a long string that won't fit in buffer";
- char buf[sizeof(source)/2]; /* make buffer half the size */
-
- /* initialise buffer with characters so it can contain no nulls */
- memset(buf, DATA_BYTE, sizeof(buf));
-
- /* run rte_snprintf and check results */
- retval = rte_snprintf(buf, sizeof(buf), "%s", source);
- if (retval != sizeof(source) - 1) {
- LOG("Error, retval = %d, expected = %u\n",
- retval, (unsigned)sizeof(source));
- return -1;
- }
- if (buf[sizeof(buf)-1] != '\0') {
- LOG("Error, buffer is not null-terminated\n");
- return -1;
- }
- if (memcmp(source, buf, sizeof(buf)-1) != 0){
- LOG("Error, corrupt data in buffer\n");
- return -1;
- }
- } while (0);
-
- do {
- /* ===========================================================
- * Test using zero-size buf to check how long a buffer we need
- * ===========================================================*/
- int retval;
- const char source[] = "This is a string";
- char buf[10];
-
- /* call with a zero-sized non-NULL buffer, should tell how big a buffer
- * we need */
- retval = rte_snprintf(buf, 0, "%s", source);
- if (retval != sizeof(source) - 1) {
- LOG("Call with 0-length buffer does not return correct size."
- "Expected: %zu, got: %d\n", sizeof(source), retval);
- return -1;
- }
-
- /* call with a zero-sized NULL buffer, should tell how big a buffer
- * we need */
- retval = rte_snprintf(NULL, 0, "%s", source);
- if (retval != sizeof(source) - 1) {
- LOG("Call with 0-length buffer does not return correct size."
- "Expected: %zu, got: %d\n", sizeof(source), retval);
- return -1;
- }
-
- } while (0);
-
- do {
- /* =================================================
- * Test with invalid parameter values
- * =================================================*/
- const char source[] = "This is a string";
- char buf[10];
-
- /* call with buffer value set to NULL is EINVAL */
- if (rte_snprintf(NULL, sizeof(buf), "%s\n", source) != -1 ||
- errno != EINVAL) {
- LOG("Failed to get suitable error when passing NULL buffer\n");
- return -1;
- }
-
- memset(buf, DATA_BYTE, sizeof(buf));
- /* call with a NULL format and zero-size should return error
- * without affecting the buffer */
- if (rte_snprintf(buf, 0, NULL) != -1 ||
- errno != EINVAL) {
- LOG("Failed to get suitable error when passing NULL buffer\n");
- return -1;
- }
- if (buf[0] != DATA_BYTE) {
- LOG("Error, zero-length buffer modified after call with NULL"
- " format string\n");
- return -1;
- }
-
- /* call with a NULL format should return error but also null-terminate
- * the buffer */
- if (rte_snprintf(buf, sizeof(buf), NULL) != -1 ||
- errno != EINVAL) {
- LOG("Failed to get suitable error when passing NULL buffer\n");
- return -1;
- }
- if (buf[0] != '\0') {
- LOG("Error, buffer not null-terminated after call with NULL"
- " format string\n");
- return -1;
- }
- } while (0);
-
- LOG("%s - PASSED\n", __func__);
- return 0;
-}
-
-static int
test_rte_strsplit(void)
{
int i;
@@ -294,8 +161,7 @@ test_rte_strsplit(void)
static int
test_string_fns(void)
{
- if (test_rte_snprintf() < 0 ||
- test_rte_strsplit() < 0)
+ if (test_rte_strsplit() < 0)
return -1;
return 0;
}
diff --git a/lib/librte_eal/common/eal_common_string_fns.c b/lib/librte_eal/common/eal_common_string_fns.c
index fb0bbe8..125a3e2 100644
--- a/lib/librte_eal/common/eal_common_string_fns.c
+++ b/lib/librte_eal/common/eal_common_string_fns.c
@@ -38,34 +38,6 @@
#include <rte_string_fns.h>
-/* safe version os snprintf */
-int
-rte_snprintf(char *buffer, int buflen, const char *format, ...)
-{
- int len;
- va_list ap;
-
- if (buffer == NULL && buflen != 0)
- goto einval_error;
- if (format == NULL) {
- if (buflen > 0)
- buffer[0] = '\0';
- goto einval_error;
- }
-
- va_start(ap, format);
- len = vsnprintf(buffer, buflen, format, ap);
- va_end(ap);
- if (len >= buflen && buflen > 0)
- buffer[buflen - 1] = '\0';
-
- return len;
-
-einval_error:
- errno = EINVAL;
- return -1;
-}
-
/* split string into tokens */
int
rte_strsplit(char *string, int stringlen,
diff --git a/lib/librte_eal/common/include/rte_string_fns.h b/lib/librte_eal/common/include/rte_string_fns.h
index cf96b2c..cfca2f8 100644
--- a/lib/librte_eal/common/include/rte_string_fns.h
+++ b/lib/librte_eal/common/include/rte_string_fns.h
@@ -45,30 +45,6 @@ extern "C" {
#endif
/**
- * This functio is deprecated and just for backward compatibility.
- * It is just an alternate version of snprintf.
- *
- * @param buffer
- * The buffer into which the output is to be written
- *
- * @param buflen
- * The size of the output buffer
- *
- * @param format
- * The format string to be printed to the buffer
- *
- * @return
- * The number of characters written to the buffer, or if the string has been
- * truncated, the number of characters which would have been written had the
- * buffer been sufficiently big.
- *
- */
-int
-rte_snprintf(char *buffer, int buflen, const char *format, ...)
- __attribute__((format(printf,3,4)))
- __attribute__((deprecated));
-
-/**
* Takes string "string" parameter and splits it at character "delim"
* up to maxtokens-1 times - to give "maxtokens" resulting tokens. Like
* strtok or strsep functions, this modifies its input string, by replacing
diff --git a/lib/librte_eal/common/include/rte_warnings.h b/lib/librte_eal/common/include/rte_warnings.h
index 423e6fb..da80877 100644
--- a/lib/librte_eal/common/include/rte_warnings.h
+++ b/lib/librte_eal/common/include/rte_warnings.h
@@ -54,10 +54,6 @@
#include <dirent.h>
#endif
-/* rte_snprintf uses snprintf, so include its definition before we poison the
- * functions, otherwise we'll get an error in it. */
-#include <rte_string_fns.h>
-
/* the following function are deemed not fully secure for use e.g. they
* do not always null-terminate arguments */
#pragma GCC poison sprintf strtok snprintf vsnprintf