All of lore.kernel.org
 help / color / mirror / Atom feed
From: Feiyu Zhu <zhufy.jy@cn.fujitsu.com>
To: <fstests@vger.kernel.org>
Cc: Feiyu Zhu <zhufy.jy@cn.fujitsu.com>
Subject: [PATCH] src/t_enospc.c: Fix an error for the loop initialization declaration
Date: Wed, 9 Dec 2020 21:59:54 -0500	[thread overview]
Message-ID: <1607569194-25989-1-git-send-email-zhufy.jy@cn.fujitsu.com> (raw)

When I compiled xfstests using the gcc(version 4.8.5), the following error occurred:
t_enospc.c: In function 'enospc_test':
t_enospc.c:88:2: error: 'for' loop initial declarations are only allowed in C99 mode
  for (int i = 0; i < size; i++) {
  ^

Signed-off-by: Feiyu Zhu <zhufy.jy@cn.fujitsu.com>
---
 src/t_enospc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/t_enospc.c b/src/t_enospc.c
index d06c676..4070ea5 100644
--- a/src/t_enospc.c
+++ b/src/t_enospc.c
@@ -44,6 +44,7 @@ void handle_sigbus(int sig)
 
 void enospc_test(int id)
 {
+	int i;
 	int fd;
 	char fpath[255] = {0};
 	char *addr;
@@ -85,7 +86,7 @@ void enospc_test(int id)
 	addr = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, 0);
 	assert(addr != MAP_FAILED);
 
-	for (int i = 0; i < size; i++) {
+	for (i = 0; i < size; i++) {
 		addr[i] = 0xAB;
 	}
 
@@ -104,10 +105,11 @@ void *spawn_test_thread(void *arg)
 
 void _run_test(int threads)
 {
+	int i;
 	pthread_t tid[threads];
 
 	pthread_barrier_init(&bar, NULL, threads+1);
-	for (int i = 0; i < threads; i++) {
+	for (i = 0; i < threads; i++) {
 		struct thread_s *thread_info = (struct thread_s *) malloc(sizeof(struct thread_s));
 		thread_info->id = i;
 		assert(pthread_create(&tid[i], NULL, spawn_test_thread, thread_info) == 0);
@@ -115,7 +117,7 @@ void _run_test(int threads)
 
 	pthread_barrier_wait(&bar);
 
-	for (int i = 0; i <threads; i++) {
+	for (i = 0; i < threads; i++) {
 		assert(pthread_join(tid[i], NULL) == 0);
 	}
 
-- 
1.8.3.1




             reply	other threads:[~2020-12-10  3:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-10  2:59 Feiyu Zhu [this message]
2020-12-16  5:21 ` [PATCH] src/t_enospc.c: Fix an error for the loop initialization declaration Ritesh Harjani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1607569194-25989-1-git-send-email-zhufy.jy@cn.fujitsu.com \
    --to=zhufy.jy@cn.fujitsu.com \
    --cc=fstests@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.