syscalls: Cast st_nlink variables to proper integers
PATCH 5/21 syscalls: Cast st_nlink variables to proper integers
Hi, please review the attached patch
Signature · 1 line
markos
From 5597051818cb71032d6d2dc9eaa16ab417e9c79e Mon Sep 17 00:00:00 2001
From: Markos Chandras <[email protected]>
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.
--- 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(-)
testcases/kernel/syscalls/link/link02.c +1 -1
@@ -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 ) {
testcases/kernel/syscalls/link/link03.c +2 -2
@@ -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++;
testcases/kernel/syscalls/link/link05.c +2 -2
@@ -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++;
testcases/kernel/syscalls/symlink/symlink01.c +2 -2
@@ -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\
Signature · 1 line
1.7.1
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 1 line · Markos Chandras
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 1 line · 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
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 4 lines · Mike Frysinger
Quoted 1 line · 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 7 lines · On Tuesday 03 January 2012 15:51:52 Garrett Cooper wrote:
Quoted 4 lines · Mike Frysinger
Quoted 1 line · 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
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 11 lines · Mike Frysinger
Quoted 7 lines · On Tuesday 03 January 2012 15:51:52 Garrett Cooper wrote:
Quoted 4 lines · Mike Frysinger
Quoted 1 line · 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 3 lines · 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 -> %zdsize_t -> %zuintmax_t -> %jduintmax_t -> %ju
-mike
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 11 lines · Mike Frysinger
Quoted 3 lines · 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-> %zdsize_t-> %zuintmax_t-> %jduintmax_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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list