Make remaining macros behave like standard statements 23/214923/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Sat, 28 Sep 2019 16:28:01 +0000 (18:28 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Sat, 28 Sep 2019 16:28:01 +0000 (18:28 +0200)
Change-Id: Id09a320422eeac2ddd459b47b023df8d4d975971

src/crash-manager/crash-manager.c

index dd2bab1..821d516 100644 (file)
@@ -534,7 +534,7 @@ end:
 }
 
 // These macros are used in functions below
-#define SNPRINTF_OR_EXIT_W(name, format, member) if (snprintf(name##_str, sizeof(name##_str), format, cinfo->member) < 0) goto out;
+#define SNPRINTF_OR_EXIT_W(name, format, member) do { if (snprintf(name##_str, sizeof(name##_str), format, cinfo->member) < 0) goto out; } while (0)
 #define SNPRINTF_OR_EXIT(name, format) SNPRINTF_OR_EXIT_W(name, format, name##_info)
 
 static bool extra_script(const struct crash_info *cinfo, pid_t *pid)
@@ -543,7 +543,7 @@ static bool extra_script(const struct crash_info *cinfo, pid_t *pid)
                return false;
 
        char pid_str[11];
-       SNPRINTF_OR_EXIT(pid, "%d")
+       SNPRINTF_OR_EXIT(pid, "%d");
 
        char *av[] = { config.extra_script, cinfo->pfx, pid_str, NULL };
        spawn_param_s param = { .fn = spawn_setstdout, .u.int_val = STDERR_FILENO };
@@ -568,9 +568,9 @@ static void launch_dbus_notify(struct crash_info *cinfo)
                return;
        }
 
-       SNPRINTF_OR_EXIT(pid, "%d")
-       SNPRINTF_OR_EXIT(tid, "%d")
-       SNPRINTF_OR_EXIT(sig, "%d")
+       SNPRINTF_OR_EXIT(pid, "%d");
+       SNPRINTF_OR_EXIT(tid, "%d");
+       SNPRINTF_OR_EXIT(sig, "%d");
 
        char *av[] = { CRASH_NOTIFY_BIN_PATH,
                        "--cmdline", cinfo->cmd_line,
@@ -604,11 +604,11 @@ static bool execute_minicoredump(struct crash_info *cinfo, int *exit_code)
 
        char pid_str[11], uid_str[11], gid_str[11], sig_str[11], time_str[11];
 
-       SNPRINTF_OR_EXIT(pid, "%d")
-       SNPRINTF_OR_EXIT(uid, "%d")
-       SNPRINTF_OR_EXIT(gid, "%d")
-       SNPRINTF_OR_EXIT(sig, "%d")
-       SNPRINTF_OR_EXIT(time, "%ld")
+       SNPRINTF_OR_EXIT(pid, "%d");
+       SNPRINTF_OR_EXIT(uid, "%d");
+       SNPRINTF_OR_EXIT(gid, "%d");
+       SNPRINTF_OR_EXIT(sig, "%d");
+       SNPRINTF_OR_EXIT(time, "%ld");
 
        /* Execute minicoredumper */
        char *args[] = {
@@ -664,7 +664,7 @@ static bool execute_livedumper(const struct crash_info *cinfo, int *exit_code)
                goto out;
        }
 
-       SNPRINTF_OR_EXIT(pid, "%d")
+       SNPRINTF_OR_EXIT(pid, "%d");
 
        /* Execute livedumper */
        char *args[] = {
@@ -689,10 +689,10 @@ static bool execute_crash_stack(const struct crash_info *cinfo, int *exit_code)
        char pid_str[11], tid_str[11], sig_str[11], prstatus_fd_str[11];
        bool is_ok = false;
 
-       SNPRINTF_OR_EXIT(pid, "%d")
-       SNPRINTF_OR_EXIT(tid, "%d")
-       SNPRINTF_OR_EXIT(sig, "%d")
-       SNPRINTF_OR_EXIT_W(prstatus_fd, "%d", prstatus_fd)
+       SNPRINTF_OR_EXIT(pid, "%d");
+       SNPRINTF_OR_EXIT(tid, "%d");
+       SNPRINTF_OR_EXIT(sig, "%d");
+       SNPRINTF_OR_EXIT_W(prstatus_fd, "%d", prstatus_fd);
 
        /* Execute crash-stack */
        char *args[] = { CRASH_STACK_BIN_PATH,