Skip to contentSkip to conversation

diotest3: fix -f argument

PATCH In review Jeff Layton 2 participants 3 messages Nov 6, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 diotest3: fix -f argument

The '-f' argument to diotest3 is currently ignored. During options processing it's copied to the buffer, then subsequently overwritten by the default in a later sprintf() call.

Move the setting of the default prior to the options processing.

---
 testcases/kernel/io/direct_io/diotest3.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
testcases/kernel/io/direct_io/diotest3.c +2 -1
index ac460ed..002a6d0 100644
@@ -238,6 +238,8 @@ int main(int argc, char *argv[])
 	int numchild = 1;	/* Number of children. Default 5 */
 	int i, fail_count = 0, failed = 0, total = 0;
 
+	sprintf(filename, "testdata-3.%ld", syscall(__NR_gettid));
+
 	/* Options */
 	while ((i = getopt(argc, argv, "b:o:i:n:f:")) != -1) {
 		switch (i) {
@@ -277,7 +279,6 @@ int main(int argc, char *argv[])
 			prg_usage();
 		}
 	}
-	sprintf(filename, "testdata-3.%ld", syscall(__NR_gettid));
 
 	setup();
 
Signature · 13 lines
1.7.1


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

----- Original Message -----

Quoted 5 lines

From: "Jeff Layton" <[email protected]>
To: [email protected]
Sent: Wednesday, 6 November, 2013 5:39:11 PM
Subject: [LTP] [PATCH] diotest3: fix -f argument

Quoted 7 lines

The '-f' argument to diotest3 is currently ignored. During options processing it's copied to the buffer, then subsequently overwritten by the default in a later sprintf() call.

Move the setting of the default prior to the options processing.

Hi Jeff,

pushed. I checked also other diotest*.c, but diotest3.c was the only one having this issue.

Thanks,
Jan

Quoted 30 lines
---
 testcases/kernel/io/direct_io/diotest3.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
testcases/kernel/io/direct_io/diotest3.c +2 -2
index ac460ed..002a6d0 100644
@@ -238,6 +238,8 @@ int main(int argc, char *argv[])
 	int numchild = 1;	/* Number of children. Default 5 */
 	int i, fail_count = 0, failed = 0, total = 0;
 
+	sprintf(filename, "testdata-3.%ld", syscall(__NR_gettid));
+
 	/* Options */
 	while ((i = getopt(argc, argv, "b:o:i:n:f:")) != -1) {
 		switch (i) {
@@ -277,7 +279,6 @@ int main(int argc, char *argv[])
 			prg_usage();
 		}
 	}
-	sprintf(filename, "testdata-3.%ld", syscall(__NR_gettid));
 
 	setup();
 
--

1.7.1

Quoted 11 lines

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#2 lore raw
Quoted 18 lines · On Wed, 6 Nov 2013 16:34:58 -0500 (EST) Jan Stancek <[email protected]> wrote:

----- Original Message -----

Quoted 5 lines

From: "Jeff Layton" <[email protected]>
To: [email protected]
Sent: Wednesday, 6 November, 2013 5:39:11 PM
Subject: [LTP] [PATCH] diotest3: fix -f argument

Quoted 7 lines

The '-f' argument to diotest3 is currently ignored. During options processing it's copied to the buffer, then subsequently overwritten by the default in a later sprintf() call.

Move the setting of the default prior to the options processing.

Quoted 8 lines

Hi Jeff,

pushed. I checked also other diotest*.c, but diotest3.c was the only one having this issue.

Thanks,
Jan

Thanks, that's what I found too. The only other (minor) problem I see is that the LEN value used in all of the diotests to size the buffer for the filename is pitifully small. It might be reasonable to get rid of that and just use PATH_MAX...

Quoted 41 lines
Quoted 41 lines
---
 testcases/kernel/io/direct_io/diotest3.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
testcases/kernel/io/direct_io/diotest3.c +2 -2
index ac460ed..002a6d0 100644
@@ -238,6 +238,8 @@ int main(int argc, char *argv[])
 	int numchild = 1;	/* Number of children. Default 5 */
 	int i, fail_count = 0, failed = 0, total = 0;
 
+	sprintf(filename, "testdata-3.%ld", syscall(__NR_gettid));
+
 	/* Options */
 	while ((i = getopt(argc, argv, "b:o:i:n:f:")) != -1) {
 		switch (i) {
@@ -277,7 +279,6 @@ int main(int argc, char *argv[])
 			prg_usage();
 		}
 	}
-	sprintf(filename, "testdata-3.%ld", syscall(__NR_gettid));
 
 	setup();
 
--

1.7.1

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Signature · 12 lines
Jeff Layton <[email protected]>

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list