From: Mathieu Desnoyers Date: Tue, 6 Feb 2018 13:58:59 +0000 (-0500) Subject: Fix: remove for() loop initial declarations X-Git-Tag: v2.9.3~9 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=edfc3ce13d439b777fb98920b296b912550e070e;p=lttng-ust.git Fix: remove for() loop initial declarations Breaks sles12sp2 builds: 08:51:35 lttng-ust-fd-tracker.c: In function 'dup_std_fd': 08:51:35 lttng-ust-fd-tracker.c:174:2: error: 'for' loop initial declarations are only allowed in C99 mode 08:51:35 for (int i = 0; i < STDERR_FILENO + 1; i++) { 08:51:35 ^ 08:51:35 lttng-ust-fd-tracker.c:174:2: note: use option -std=c99 or -std=gnu99 to compile your code 08:51:35 lttng-ust-fd-tracker.c:195:11: error: redefinition of 'i' 08:51:35 for (int i = 0; i < fd_to_close_count; i++) { 08:51:35 ^ 08:51:35 lttng-ust-fd-tracker.c:174:11: note: previous definition of 'i' was here 08:51:35 for (int i = 0; i < STDERR_FILENO + 1; i++) { 08:51:35 ^ 08:51:35 lttng-ust-fd-tracker.c:195:2: error: 'for' loop initial declarations are only allowed in C99 mode 08:51:35 for (int i = 0; i < fd_to_close_count; i++) { 08:51:35 ^ 08:51:35 Makefile:412: recipe for target 'lttng-ust-fd-tracker.lo' failed 08:51:35 make[2]: *** [lttng-ust-fd-tracker.lo] Error 1 08:51:35 make[2]: *** Waiting for unfinished jobs.... Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-comm/lttng-ust-fd-tracker.c b/liblttng-ust-comm/lttng-ust-fd-tracker.c index 329339f9..1bc186bf 100644 --- a/liblttng-ust-comm/lttng-ust-fd-tracker.c +++ b/liblttng-ust-comm/lttng-ust-fd-tracker.c @@ -146,7 +146,7 @@ void lttng_ust_unlock_fd_tracker(void) static int dup_std_fd(int fd) { - int ret; + int ret, i; int fd_to_close[STDERR_FILENO + 1]; int fd_to_close_count = 0; int dup_cmd = F_DUPFD; /* Default command */ @@ -171,7 +171,7 @@ static int dup_std_fd(int fd) } /* Perform dup */ - for (int i = 0; i < STDERR_FILENO + 1; i++) { + for (i = 0; i < STDERR_FILENO + 1; i++) { ret = fcntl(fd, dup_cmd, 0); if (ret < 0) { PERROR("fcntl dup fd"); @@ -192,7 +192,7 @@ static int dup_std_fd(int fd) } /* Close intermediary fds */ - for (int i = 0; i < fd_to_close_count; i++) { + for (i = 0; i < fd_to_close_count; i++) { ret = close(fd_to_close[i]); if (ret) { PERROR("close on temporary fd: %d.", fd_to_close[i]);