public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [COMMITTED] debuginfod: Fix formatting in debuginfod_config_cache
@ 2023-06-22 12:54 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2023-06-22 12:54 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

The formatting of debuginfod_config_cache in debuginfod-client.c was
slightly off making it hard to see the program logic. Make sure lines
are < 76 chars, and if { } else { } indentation follows GNU style.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 debuginfod/debuginfod-client.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
index cb28f1d0..d92d8d62 100644
--- a/debuginfod/debuginfod-client.c
+++ b/debuginfod/debuginfod-client.c
@@ -277,23 +277,27 @@ debuginfod_config_cache(debuginfod_client *c, char *config_path,
     }
 
   long cache_config;
-  /* PR29696 - NB: When using fdopen, the file descriptor is NOT dup'ed and will
-  be closed when the stream is closed. Manually closing fd after fclose
-  is called will lead to a race condition where, if reused, the file descriptor will
-  compete for its regular use before being incorrectly closed here.
-  */
+  /* PR29696 - NB: When using fdopen, the file descriptor is NOT
+     dup'ed and will be closed when the stream is closed. Manually
+     closing fd after fclose is called will lead to a race condition
+     where, if reused, the file descriptor will compete for its
+     regular use before being incorrectly closed here.  */
   FILE *config_file = fdopen(fd, "r");
   if (config_file)
-  {
-    if (fscanf(config_file, "%ld", &cache_config) != 1)
+    {
+      if (fscanf(config_file, "%ld", &cache_config) != 1)
+	cache_config = cache_config_default_s;
+      if (0 != fclose (config_file) && c->verbose_fd >= 0)
+	dprintf (c->verbose_fd, "fclose failed with %s (err=%d)\n",
+		 strerror (errno), errno);
+    }
+  else
+    {
       cache_config = cache_config_default_s;
-    if(0 != fclose(config_file) && c->verbose_fd >= 0)
-      dprintf (c->verbose_fd, "fclose failed with %s (err=%d)\n", strerror (errno), errno);
-  }else{
-    cache_config = cache_config_default_s;
-    if(0 != close(fd) && c->verbose_fd >= 0)
-      dprintf (c->verbose_fd, "close failed with %s (err=%d)\n", strerror (errno), errno);
-  }
+      if (0 != close (fd) && c->verbose_fd >= 0)
+	dprintf (c->verbose_fd, "close failed with %s (err=%d)\n",
+		 strerror (errno), errno);
+    }
   return cache_config;
 }
 
-- 
2.40.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-22 12:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22 12:54 [COMMITTED] debuginfod: Fix formatting in debuginfod_config_cache Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).