[v2,1/3] support: don't pass to set_search_path a big struct by value
diff mbox series

Message ID 20190331174420.30823-2-Hi-Angel@yandex.ru
State New
Headers show
Series
  • Minor LGTM fixes
Related show

Commit Message

Konstantin Kharlamov March 31, 2019, 5:44 p.m. UTC
Fixes LGTM warning: " This parameter of type resolv_redirect_config is
88 bytes - consider passing a const pointer/reference instead."

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
---
 support/resolv_test.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Patch
diff mbox series

diff --git a/support/resolv_test.c b/support/resolv_test.c
index 903ab2ac05..f400026cd1 100644
--- a/support/resolv_test.c
+++ b/support/resolv_test.c
@@ -1079,7 +1079,7 @@  resolv_test_init (void)
 
 /* Copy the search path from CONFIG.search to the _res object.  */
 static void
-set_search_path (struct resolv_redirect_config config)
+set_search_path (const struct resolv_redirect_config* config)
 {
   memset (_res.defdname, 0, sizeof (_res.defdname));
   memset (_res.dnsrch, 0, sizeof (_res.dnsrch));
@@ -1088,15 +1088,15 @@  set_search_path (struct resolv_redirect_config config)
   char *end = current + sizeof (_res.defdname);
 
   for (unsigned int i = 0;
-       i < sizeof (config.search) / sizeof (config.search[0]); ++i)
+       i < sizeof (config->search) / sizeof (config->search[0]); ++i)
     {
-      if (config.search[i] == NULL)
+      if (config->search[i] == NULL)
         continue;
 
-      size_t length = strlen (config.search[i]) + 1;
+      size_t length = strlen (config->search[i]) + 1;
       size_t remaining = end - current;
       TEST_VERIFY_EXIT (length <= remaining);
-      memcpy (current, config.search[i], length);
+      memcpy (current, config->search[i], length);
       _res.dnsrch[i] = current;
       current += length;
     }
@@ -1203,7 +1203,7 @@  resolv_test_start (struct resolv_redirect_config config)
         }
     }
 
-  set_search_path (config);
+  set_search_path (&config);
 
   return obj;
 }