* [PATCH] src/t_enospc.c: Fix an error for the loop initialization declaration
@ 2020-12-10 2:59 Feiyu Zhu
2020-12-16 5:21 ` Ritesh Harjani
0 siblings, 1 reply; 2+ messages in thread
From: Feiyu Zhu @ 2020-12-10 2:59 UTC (permalink / raw)
To: fstests; +Cc: Feiyu Zhu
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] src/t_enospc.c: Fix an error for the loop initialization declaration
2020-12-10 2:59 [PATCH] src/t_enospc.c: Fix an error for the loop initialization declaration Feiyu Zhu
@ 2020-12-16 5:21 ` Ritesh Harjani
0 siblings, 0 replies; 2+ messages in thread
From: Ritesh Harjani @ 2020-12-16 5:21 UTC (permalink / raw)
To: Feiyu Zhu, fstests
On 12/10/20 8:29 AM, Feiyu Zhu wrote:
> 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>
Thanks for your patch. LGTM, please feel free to add.
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-16 5:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-10 2:59 [PATCH] src/t_enospc.c: Fix an error for the loop initialization declaration Feiyu Zhu
2020-12-16 5:21 ` Ritesh Harjani
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.