On 3/25/21 11:16 AM, Paul Eggert wrote:
I'd prefer it to use IF_LINT (as in the earlier change), as that makes it cleaner since it's just one line of useless code, not three.
Installed as attached, and closing the bug report. Thanks again.
>From d3749c46056ddeb1314f35b1644f52179d7a3502 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 25 Mar 2021 11:20:18 -0700
Subject: [PATCH] hostname: pacify valgrind

* src/hostname.c (main) [IF_LINT]: Free hostname (Bug#47384).
---
 src/hostname.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/hostname.c b/src/hostname.c
index 008682f39..94b070582 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -104,6 +104,7 @@ main (int argc, char **argv)
       if (hostname == NULL)
         die (EXIT_FAILURE, errno, _("cannot determine hostname"));
       puts (hostname);
+      IF_LINT (free (hostname));
     }
 
   if (optind + 1 < argc)
-- 
2.27.0

Reply via email to