qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 39/39] util/log: Support per-thread log files


From: Richard Henderson
Subject: Re: [PATCH v2 39/39] util/log: Support per-thread log files
Date: Thu, 14 Apr 2022 09:32:43 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

On 4/14/22 08:35, Alex Bennée wrote:
+/**
+ * valid_filename_template:
+ *
+ * Validate the filename template.  Require %d if per_thread, allow it
+ * otherwise; require no other % within the template.
+ * Return 0 if invalid, 1 if stderr, 2 if strdup, 3 if pid printf.

 From a neatness point of view having an enum would make it easier to
read in the switch down bellow...

Fair, and...

+        switch (valid_filename_template(filename, per_thread, errp)) {
+        case 0:
+            return false; /* error */
+        case 1:
+            break;  /* stderr */
+        case 2:
+            newname = g_strdup(filename);
+            break;
+        case 3:
+            newname = g_strdup_printf(filename, getpid());
+            break;

default: g_assert_not_reached?

... using an enum with an extra enumerator for testing gives us

../src/util/log.c: In function ‘qemu_set_log_internal’:
../src/util/log.c:213:9: error: enumeration value ‘vft_new_case’ not handled in switch [-Werror=switch]
  213 |         switch (valid_filename_template(filename, per_thread, errp)) {
      |         ^~~~~~
cc1: all warnings being treated as errors

though that does require *not* having a default case.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]