* [LTP] [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero
@ 2012-01-03 11:04 Markos Chandras
2012-01-03 19:37 ` Garrett Cooper
2012-01-03 20:38 ` Mike Frysinger
0 siblings, 2 replies; 5+ messages in thread
From: Markos Chandras @ 2012-01-03 11:04 UTC (permalink / raw)
To: ltp-list
[-- Attachment #1: Type: text/plain, Size: 49 bytes --]
Hi, please review the attached patch
--
markos
[-- Attachment #2: 0008-syscalls-remap_file_pages-unsigned-int-is-always-gre.patch --]
[-- Type: text/plain, Size: 2185 bytes --]
From 91f35a787627ef3bfb77dd0f0dc5e8993016b0b5 Mon Sep 17 00:00:00 2001
From: Markos Chandras <markos.chandras@imgtec.com>
Date: Thu, 22 Dec 2011 13:05:58 +0000
Subject: [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero
getpagesize() returns an integer value ( which can be negative in case of
an error ). However, when a negative value is assigned to unsigned int, the
result is a much greater integer (2's complement), therefore the expression
page_sz > 0 is always true. A getpagesize() error won't be noticed in this case
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
.../syscalls/remap_file_pages/remap_file_pages01.c | 6 +++---
.../syscalls/remap_file_pages/remap_file_pages02.c | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/remap_file_pages/remap_file_pages01.c b/testcases/kernel/syscalls/remap_file_pages/remap_file_pages01.c
index 01fd291..fa1bdca 100644
--- a/testcases/kernel/syscalls/remap_file_pages/remap_file_pages01.c
+++ b/testcases/kernel/syscalls/remap_file_pages/remap_file_pages01.c
@@ -231,11 +231,11 @@ void setup()
TEST_PAUSE;
/* Get page size */
- if ((page_sz = getpagesize()) < 0) {
+ if (getpagesize() < 0) {
tst_brkm(TFAIL, cleanup,
"getpagesize() fails to get system page size");
}
-
+ page_sz = getpagesize();
page_words = (page_sz / sizeof(char));
/* Set the cache size */
@@ -287,4 +287,4 @@ void cleanup(char *data)
tst_rmdir();
-}
\ No newline at end of file
+}
diff --git a/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c b/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c
index c30abe8..c70bfe8 100644
--- a/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c
+++ b/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c
@@ -281,11 +281,11 @@ void setup()
tst_tmpdir();
/* Get page size */
- if ((page_sz = getpagesize()) < 0) {
+ if (getpagesize() < 0) {
tst_brkm(TFAIL, cleanup,
"getpagesize() fails to get system page size");
}
-
+ page_sz = getpagesize();
page_words = (page_sz / sizeof(char));
/* Set the cache size */
--
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] 5+ messages in thread* Re: [LTP] [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero
2012-01-03 11:04 [LTP] [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero Markos Chandras
@ 2012-01-03 19:37 ` Garrett Cooper
2012-01-03 20:38 ` Mike Frysinger
1 sibling, 0 replies; 5+ messages in thread
From: Garrett Cooper @ 2012-01-03 19:37 UTC (permalink / raw)
To: Markos Chandras; +Cc: ltp-list
On Tue, Jan 3, 2012 at 3:04 AM, Markos Chandras
<Markos.Chandras@imgtec.com> wrote:
> Hi, please review the attached patch
Reviewed-by: Garrett Cooper <yanegomi@gmail.com>
------------------------------------------------------------------------------
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] 5+ messages in thread
* Re: [LTP] [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero
2012-01-03 11:04 [LTP] [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero Markos Chandras
2012-01-03 19:37 ` Garrett Cooper
@ 2012-01-03 20:38 ` Mike Frysinger
2012-01-04 14:34 ` Cyril Hrubis
1 sibling, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2012-01-03 20:38 UTC (permalink / raw)
To: ltp-list; +Cc: Markos Chandras
[-- Attachment #1.1: Type: Text/Plain, Size: 267 bytes --]
On Tuesday 03 January 2012 06:04:38 Markos Chandras wrote:
> Hi, please review the attached patch
you should add a local int variable, store getpagesize() into that, and then
use that to initialize page_sz rather than call getpagesize() multiple times.
-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] 5+ messages in thread
* Re: [LTP] [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero
2012-01-03 20:38 ` Mike Frysinger
@ 2012-01-04 14:34 ` Cyril Hrubis
[not found] ` <201201041358.21225.vapier@gentoo.org>
0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2012-01-04 14:34 UTC (permalink / raw)
To: Mike Frysinger; +Cc: ltp-list, Markos Chandras
Hi!
> you should add a local int variable, store getpagesize() into that, and then
> use that to initialize page_sz rather than call getpagesize() multiple times.
That would be better.
And moreover isn't sizeof(char) == 1 by definition?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-05 10:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03 11:04 [LTP] [PATCH 08/21] syscalls/remap_file_pages: unsigned int is always greater to zero Markos Chandras
2012-01-03 19:37 ` Garrett Cooper
2012-01-03 20:38 ` Mike Frysinger
2012-01-04 14:34 ` Cyril Hrubis
[not found] ` <201201041358.21225.vapier@gentoo.org>
2012-01-05 10:45 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox