eal: remove size for setting runtime directory
authorStephen Hemminger <stephen@networkplumber.org>
Wed, 9 Feb 2022 06:54:01 +0000 (22:54 -0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 9 Feb 2022 15:42:31 +0000 (16:42 +0100)
The size argument to eal_set_runtime_dir is useless and was
being used incorrectly in strlcpy. It worked only because
all callers passed PATH_MAX which is same as sizeof the destination
runtime_dir.

Note: this is an internal API so no user exposed change.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
lib/eal/common/eal_common_config.c
lib/eal/common/eal_private.h
lib/eal/freebsd/eal.c
lib/eal/linux/eal.c

index 6d19aad..3cef43a 100644 (file)
@@ -29,12 +29,9 @@ rte_eal_get_runtime_dir(void)
 }
 
 int
-eal_set_runtime_dir(char *run_dir, size_t size)
+eal_set_runtime_dir(const char *run_dir)
 {
-       size_t str_size;
-
-       str_size = strlcpy(runtime_dir, run_dir, size);
-       if (str_size >= size) {
+       if (strlcpy(runtime_dir, run_dir, PATH_MAX) >= PATH_MAX) {
                RTE_LOG(ERR, EAL, "Runtime directory string too long\n");
                return -1;
        }
index 36bcc0b..734f1f3 100644 (file)
@@ -681,13 +681,11 @@ eal_mem_set_dump(void *virt, size_t size, bool dump);
  *
  * @param run_dir
  *   The new runtime directory path of DPDK
- * @param size
- *   The size of the new runtime directory path in bytes.
  * @return
  *   0 on success, (-1) on failure.
  */
 int
-eal_set_runtime_dir(char *run_dir, size_t size);
+eal_set_runtime_dir(const char *run_dir);
 
 /**
  * Get the internal configuration structure.
index a1cd246..503e276 100644 (file)
@@ -123,7 +123,7 @@ eal_create_runtime_dir(void)
                return -1;
        }
 
-       if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
+       if (eal_set_runtime_dir(run_dir))
                return -1;
 
        return 0;
index 9c8395a..e37372a 100644 (file)
@@ -137,7 +137,7 @@ eal_create_runtime_dir(void)
                return -1;
        }
 
-       if (eal_set_runtime_dir(run_dir, sizeof(run_dir)))
+       if (eal_set_runtime_dir(run_dir))
                return -1;
 
        return 0;