public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
@ 2012-01-03 10:42 Markos Chandras
  2012-01-03 19:35 ` Garrett Cooper
  2012-01-03 20:37 ` Mike Frysinger
  0 siblings, 2 replies; 8+ messages in thread
From: Markos Chandras @ 2012-01-03 10:42 UTC (permalink / raw)
  To: ltp-list

[-- Attachment #1: Type: text/plain, Size: 49 bytes --]

Hi, please review the attached patch

-- 
markos

[-- Attachment #2: 0005-syscalls-Cast-st_nlink-variables-to-proper-integers.patch --]
[-- Type: text/plain, Size: 3759 bytes --]

From 5597051818cb71032d6d2dc9eaa16ab417e9c79e Mon Sep 17 00:00:00 2001
From: Markos Chandras <markos.chandras@imgtec.com>
Date: Thu, 22 Dec 2011 11:44:18 +0000
Subject: [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers

st_nlink type is arch specific so it may not be a 32-bit integer everywhere.
Since %d modifier expects an integer, the st_nlink variables need to be casted
to an integer type.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
 testcases/kernel/syscalls/link/link02.c       |    2 +-
 testcases/kernel/syscalls/link/link03.c       |    4 ++--
 testcases/kernel/syscalls/link/link05.c       |    4 ++--
 testcases/kernel/syscalls/symlink/symlink01.c |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/link/link02.c b/testcases/kernel/syscalls/link/link02.c
index 4ddd818..f6cdf9f 100644
--- a/testcases/kernel/syscalls/link/link02.c
+++ b/testcases/kernel/syscalls/link/link02.c
@@ -190,7 +190,7 @@ int main(int ac, char **av)
 					tst_resm(TFAIL,
 						 "link(%s, %s) returned %ld, stat link cnts do not match %d %d",
 						 Fname, Lname, TEST_RETURN,
-						 fbuf.st_nlink, lbuf.st_nlink);
+						 (int)fbuf.st_nlink, (int)lbuf.st_nlink);
 				}
 			}
 			if (unlink(Lname) == -1) {
diff --git a/testcases/kernel/syscalls/link/link03.c b/testcases/kernel/syscalls/link/link03.c
index f2f85b5..b3b4387 100644
--- a/testcases/kernel/syscalls/link/link03.c
+++ b/testcases/kernel/syscalls/link/link03.c
@@ -232,7 +232,7 @@ int main(int ac, char **av)
 						 "link(%s, %s[1-%d]) ret %ld for %d files, stat values do not match %d %d",
 						 Fname, Basename, nlinks,
 						 TEST_RETURN, nlinks,
-						 fbuf.st_nlink, lbuf.st_nlink);
+						 (int)fbuf.st_nlink, (int)lbuf.st_nlink);
 					break;
 				}
 			}
@@ -240,7 +240,7 @@ int main(int ac, char **av)
 				tst_resm(TPASS,
 					 "link(%s, %s[1-%d]) ret %ld for %d files, stat linkcounts match %d",
 					 Fname, Basename, nlinks, TEST_RETURN,
-					 nlinks, fbuf.st_nlink);
+					 nlinks, (int)fbuf.st_nlink);
 			}
 		} else
 			Tst_count++;
diff --git a/testcases/kernel/syscalls/link/link05.c b/testcases/kernel/syscalls/link/link05.c
index 343db1b..f03a149 100644
--- a/testcases/kernel/syscalls/link/link05.c
+++ b/testcases/kernel/syscalls/link/link05.c
@@ -217,7 +217,7 @@ int main(int ac, char **av)
 						 "link(%s, %s[1-%d]) ret %ld for %d files, stat values do not match %d %d",
 						 Fname, Basename, nlinks,
 						 TEST_RETURN, nlinks,
-						 fbuf.st_nlink, lbuf.st_nlink);
+						 (int)fbuf.st_nlink, (int)lbuf.st_nlink);
 					break;
 				}
 			}
@@ -225,7 +225,7 @@ int main(int ac, char **av)
 				tst_resm(TPASS,
 					 "link(%s, %s[1-%d]) ret %ld for %d files, stat linkcounts match %d",
 					 Fname, Basename, nlinks, TEST_RETURN,
-					 nlinks, fbuf.st_nlink);
+					 nlinks, (int)fbuf.st_nlink);
 			}
 		} else
 			Tst_count++;
diff --git a/testcases/kernel/syscalls/symlink/symlink01.c b/testcases/kernel/syscalls/symlink/symlink01.c
index c7be331..94596d0 100644
--- a/testcases/kernel/syscalls/symlink/symlink01.c
+++ b/testcases/kernel/syscalls/symlink/symlink01.c
@@ -1556,8 +1556,8 @@ struct all_test_cases *tc_ptr;
 						tst_resm(TFAIL,
 							 "%slink(%s, %s) failed to adjust link count.\n\
 		count for nick is %d, count for %s is %d, count for %s is %d.",
-							 Buffer, tc_ptr->fn_arg[1], "nick", statter.st_nlink, tc_ptr->fn_arg[1], asymlink.st_nlink, tc_ptr->fn_arg[2],
-							 stbuf.st_nlink);
+							 Buffer, tc_ptr->fn_arg[1], "nick", (int)statter.st_nlink, tc_ptr->fn_arg[1], (int)asymlink.st_nlink, tc_ptr->fn_arg[2],
+							(int) stbuf.st_nlink);
 					}
 				} else {
 					tst_resm(TFAIL, "%sA lstat of %s (ino:%jd) and of\n\t\t\
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 355 bytes --]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
  2012-01-03 10:42 [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers Markos Chandras
@ 2012-01-03 19:35 ` Garrett Cooper
  2012-01-03 20:37 ` Mike Frysinger
  1 sibling, 0 replies; 8+ messages in thread
From: Garrett Cooper @ 2012-01-03 19:35 UTC (permalink / raw)
  To: Markos Chandras; +Cc: ltp-list

On Tue, Jan 3, 2012 at 2:42 AM, Markos Chandras
<Markos.Chandras@imgtec.com> wrote:
> Hi, please review the attached patch

    Too bad it is a longtype, unlike BSD. Maybe you want to make this
into a zu format string qualifier instead?
Thanks!
-Garrett

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
  2012-01-03 10:42 [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers Markos Chandras
  2012-01-03 19:35 ` Garrett Cooper
@ 2012-01-03 20:37 ` Mike Frysinger
  2012-01-03 20:51   ` Garrett Cooper
  1 sibling, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-01-03 20:37 UTC (permalink / raw)
  To: ltp-list; +Cc: Markos Chandras


[-- Attachment #1.1: Type: Text/Plain, Size: 141 bytes --]

On Tuesday 03 January 2012 05:42:55 Markos Chandras wrote:
> Hi, please review the attached patch

casting to a (long) would be better
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 355 bytes --]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
  2012-01-03 20:37 ` Mike Frysinger
@ 2012-01-03 20:51   ` Garrett Cooper
  2012-01-03 20:57     ` Mike Frysinger
  0 siblings, 1 reply; 8+ messages in thread
From: Garrett Cooper @ 2012-01-03 20:51 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list, Markos Chandras

On Tue, Jan 3, 2012 at 12:37 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 03 January 2012 05:42:55 Markos Chandras wrote:
>> Hi, please review the attached patch
>
> casting to a (long) would be better

Or uintmax_t...
-Garrett

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
  2012-01-03 20:51   ` Garrett Cooper
@ 2012-01-03 20:57     ` Mike Frysinger
  2012-01-03 22:19       ` Garrett Cooper
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-01-03 20:57 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, Markos Chandras


[-- Attachment #1.1: Type: Text/Plain, Size: 453 bytes --]

On Tuesday 03 January 2012 15:51:52 Garrett Cooper wrote:
> On Tue, Jan 3, 2012 at 12:37 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On Tuesday 03 January 2012 05:42:55 Markos Chandras wrote:
> >> Hi, please review the attached patch
> > 
> > casting to a (long) would be better
> 
> Or uintmax_t...

that would work too, and better.  i thought nlinks could be signed, but it 
seems not, so any signed type would be not as good.
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 355 bytes --]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
  2012-01-03 20:57     ` Mike Frysinger
@ 2012-01-03 22:19       ` Garrett Cooper
  2012-01-03 23:34         ` Mike Frysinger
  0 siblings, 1 reply; 8+ messages in thread
From: Garrett Cooper @ 2012-01-03 22:19 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list, Markos Chandras

On Tue, Jan 3, 2012 at 12:57 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 03 January 2012 15:51:52 Garrett Cooper wrote:
>> On Tue, Jan 3, 2012 at 12:37 PM, Mike Frysinger <vapier@gentoo.org> wrote:
>> > On Tuesday 03 January 2012 05:42:55 Markos Chandras wrote:
>> >> Hi, please review the attached patch
>> >
>> > casting to a (long) would be better
>>
>> Or uintmax_t...
>
> that would work too, and better.  i thought nlinks could be signed, but it
> seems not, so any signed type would be not as good.

   FreeBSD seems to typedef it to uint32_t, so unsigned integers seems
like the best way to go... yeah. The 'solution' for the issues with
format strings and long integers is generally cast to [u]intmax_t,
then use %zd or %zu.
Cheers,
-Garrett

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
  2012-01-03 22:19       ` Garrett Cooper
@ 2012-01-03 23:34         ` Mike Frysinger
  2012-01-03 23:52           ` Garrett Cooper
  0 siblings, 1 reply; 8+ messages in thread
From: Mike Frysinger @ 2012-01-03 23:34 UTC (permalink / raw)
  To: Garrett Cooper; +Cc: ltp-list, Markos Chandras


[-- Attachment #1.1: Type: Text/Plain, Size: 272 bytes --]

On Tuesday 03 January 2012 17:19:25 Garrett Cooper wrote:
> The 'solution' for the issues with
> format strings and long integers is generally cast to [u]intmax_t,
> then use %zd or %zu.

eek, almost ;)

ssize_t -> %zd
size_t -> %zu
intmax_t -> %jd
uintmax_t -> %ju
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 355 bytes --]

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers
  2012-01-03 23:34         ` Mike Frysinger
@ 2012-01-03 23:52           ` Garrett Cooper
  0 siblings, 0 replies; 8+ messages in thread
From: Garrett Cooper @ 2012-01-03 23:52 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: ltp-list, Markos Chandras

On Tue, Jan 3, 2012 at 3:34 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Tuesday 03 January 2012 17:19:25 Garrett Cooper wrote:
>> The 'solution' for the issues with
>> format strings and long integers is generally cast to [u]intmax_t,
>> then use %zd or %zu.
>
> eek, almost ;)
>
> ssize_t -> %zd
> size_t -> %zu
> intmax_t -> %jd
> uintmax_t -> %ju

Yeah (lol)... thanks for the correction :)!
-Garrett

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-03 23:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03 10:42 [LTP] [PATCH 05/21] syscalls: Cast st_nlink variables to proper integers Markos Chandras
2012-01-03 19:35 ` Garrett Cooper
2012-01-03 20:37 ` Mike Frysinger
2012-01-03 20:51   ` Garrett Cooper
2012-01-03 20:57     ` Mike Frysinger
2012-01-03 22:19       ` Garrett Cooper
2012-01-03 23:34         ` Mike Frysinger
2012-01-03 23:52           ` Garrett Cooper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox