* [LTP] [PATCH] clone06: legitimate zero as sprintf return value
@ 2012-02-14 10:33 Salvatore CRO'
2012-02-14 11:03 ` [LTP] Fwd: " Salvatore CRO'
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Salvatore CRO' @ 2012-02-14 10:33 UTC (permalink / raw)
To: ltp-list
A return value of 0 for sprintf is acceptable as
it means zero byte read.
Indeed errno is not set in this case thus no warning
messages must be issued.
Signed-off-by: Salvatore Cro <salvatore.cro@st.com>
---
testcases/kernel/syscalls/clone/clone06.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
index 5db183b..8ba7c13 100644
--- a/testcases/kernel/syscalls/clone/clone06.c
+++ b/testcases/kernel/syscalls/clone/clone06.c
@@ -199,7 +199,7 @@ int child_environ(void)
tst_brkm(TBROK|TERRNO, cleanup, "close(pfd[0]) failed");
}
- if ((sprintf(var, "%s", getenv("TERM") ? : "")) <= 0) {
+ if ((sprintf(var, "%s", getenv("TERM") ? : "")) < 0) {
tst_resm(TWARN|TERRNO, "sprintf() failed");
}
--
1.7.4.4
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
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
* [LTP] Fwd: [PATCH] clone06: legitimate zero as sprintf return value
2012-02-14 10:33 [LTP] [PATCH] clone06: legitimate zero as sprintf return value Salvatore CRO'
@ 2012-02-14 11:03 ` Salvatore CRO'
2012-02-14 11:13 ` [LTP] [PATCH V2] clone06: set child_env to getenv directly Salvatore CRO'
2012-02-29 16:51 ` [LTP] [PATCH] clone06: legitimate zero as sprintf return value Cyril Hrubis
2 siblings, 0 replies; 8+ messages in thread
From: Salvatore CRO' @ 2012-02-14 11:03 UTC (permalink / raw)
To: ltp-list
To be honest I don't see any reason to have the sprintf at all.
I will refine my patch to directly evaluate string var to getenv...
-------- Original Message --------
Return-Path: <salvatore.cro@st.com>
Received: from localhost (lxmcdt5.ctn.st.com [164.130.129.175]) by
mail7.sgp.st.com (MOS 4.3.3-GA) with ESMTP id ALM11201 (AUTH cros); Tue,
14 Feb 2012 11:33:12 +0100
From: Salvatore CRO' <salvatore.cro@st.com>
To: ltp-list@lists.sourceforge.net
Cc: Salvatore Cro <salvatore.cro@st.com>
Subject: [PATCH] clone06: legitimate zero as sprintf return value
Date: Tue, 14 Feb 2012 11:33:01 +0100
Message-Id: <1329215581-26357-1-git-send-email-salvatore.cro@st.com>
X-Mailer: git-send-email 1.7.4.4
A return value of 0 for sprintf is acceptable as
it means zero byte read.
Indeed errno is not set in this case thus no warning
messages must be issued.
Signed-off-by: Salvatore Cro<salvatore.cro@st.com>
---
testcases/kernel/syscalls/clone/clone06.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
index 5db183b..8ba7c13 100644
--- a/testcases/kernel/syscalls/clone/clone06.c
+++ b/testcases/kernel/syscalls/clone/clone06.c
@@ -199,7 +199,7 @@ int child_environ(void)
tst_brkm(TBROK|TERRNO, cleanup, "close(pfd[0]) failed");
}
- if ((sprintf(var, "%s", getenv("TERM") ? : ""))<= 0) {
+ if ((sprintf(var, "%s", getenv("TERM") ? : ""))< 0) {
tst_resm(TWARN|TERRNO, "sprintf() failed");
}
--
1.7.4.4
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
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
* [LTP] [PATCH V2] clone06: set child_env to getenv directly
2012-02-14 10:33 [LTP] [PATCH] clone06: legitimate zero as sprintf return value Salvatore CRO'
2012-02-14 11:03 ` [LTP] Fwd: " Salvatore CRO'
@ 2012-02-14 11:13 ` Salvatore CRO'
2012-02-14 11:24 ` Carmelo AMOROSO
2012-02-23 18:29 ` Cyril Hrubis
2012-02-29 16:51 ` [LTP] [PATCH] clone06: legitimate zero as sprintf return value Cyril Hrubis
2 siblings, 2 replies; 8+ messages in thread
From: Salvatore CRO' @ 2012-02-14 11:13 UTC (permalink / raw)
To: ltp-list
sprintf check is bugged as a return value of 0 is acceptable.
Furthermore sprintf to set the child env var is unneeded.
Drop sprintf call as child_env can be set to getenv directly.
Signed-off-by: Salvatore Cro <salvatore.cro@st.com>
---
testcases/kernel/syscalls/clone/clone06.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
index 5db183b..50c8ef3 100644
--- a/testcases/kernel/syscalls/clone/clone06.c
+++ b/testcases/kernel/syscalls/clone/clone06.c
@@ -192,18 +192,16 @@ void cleanup()
int child_environ(void)
{
- char var[MAX_LINE_LENGTH];
+ char *child_env;
/* Close read end from child */
if ((close(pfd[0])) == -1) {
tst_brkm(TBROK|TERRNO, cleanup, "close(pfd[0]) failed");
}
- if ((sprintf(var, "%s", getenv("TERM") ? : "")) <= 0) {
- tst_resm(TWARN|TERRNO, "sprintf() failed");
- }
+ child_env = getenv("TERM") ? : "";
- if ((write(pfd[1], var, MAX_LINE_LENGTH)) == -1) {
+ if ((write(pfd[1], child_env, MAX_LINE_LENGTH)) == -1) {
tst_resm(TWARN|TERRNO, "write to pipe failed");
}
--
1.7.4.4
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
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 V2] clone06: set child_env to getenv directly
2012-02-14 11:13 ` [LTP] [PATCH V2] clone06: set child_env to getenv directly Salvatore CRO'
@ 2012-02-14 11:24 ` Carmelo AMOROSO
2012-02-23 18:29 ` Cyril Hrubis
1 sibling, 0 replies; 8+ messages in thread
From: Carmelo AMOROSO @ 2012-02-14 11:24 UTC (permalink / raw)
To: ltp-list
On 14/02/2012 12.13, Salvatore CRO' wrote:
> sprintf check is bugged as a return value of 0 is acceptable.
> Furthermore sprintf to set the child env var is unneeded.
> Drop sprintf call as child_env can be set to getenv directly.
>
> Signed-off-by: Salvatore Cro <salvatore.cro@st.com>
Acked-by: Carmelo Amoroso <carmelo.amoroso@st.com>
> ---
> testcases/kernel/syscalls/clone/clone06.c | 8 +++-----
> 1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
> index 5db183b..50c8ef3 100644
> --- a/testcases/kernel/syscalls/clone/clone06.c
> +++ b/testcases/kernel/syscalls/clone/clone06.c
> @@ -192,18 +192,16 @@ void cleanup()
> int child_environ(void)
> {
>
> - char var[MAX_LINE_LENGTH];
> + char *child_env;
>
> /* Close read end from child */
> if ((close(pfd[0])) == -1) {
> tst_brkm(TBROK|TERRNO, cleanup, "close(pfd[0]) failed");
> }
>
> - if ((sprintf(var, "%s", getenv("TERM") ? : "")) <= 0) {
> - tst_resm(TWARN|TERRNO, "sprintf() failed");
> - }
> + child_env = getenv("TERM") ? : "";
>
> - if ((write(pfd[1], var, MAX_LINE_LENGTH)) == -1) {
> + if ((write(pfd[1], child_env, MAX_LINE_LENGTH)) == -1) {
> tst_resm(TWARN|TERRNO, "write to pipe failed");
> }
>
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
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 V2] clone06: set child_env to getenv directly
2012-02-14 11:13 ` [LTP] [PATCH V2] clone06: set child_env to getenv directly Salvatore CRO'
2012-02-14 11:24 ` Carmelo AMOROSO
@ 2012-02-23 18:29 ` Cyril Hrubis
2012-02-23 18:30 ` Cyril Hrubis
[not found] ` <4F474AF7.1070901@st.com>
1 sibling, 2 replies; 8+ messages in thread
From: Cyril Hrubis @ 2012-02-23 18:29 UTC (permalink / raw)
To: Salvatore CRO'; +Cc: ltp-list
Hi!
> Signed-off-by: Salvatore Cro <salvatore.cro@st.com>
> ---
> testcases/kernel/syscalls/clone/clone06.c | 8 +++-----
> 1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
> index 5db183b..50c8ef3 100644
> --- a/testcases/kernel/syscalls/clone/clone06.c
> +++ b/testcases/kernel/syscalls/clone/clone06.c
> @@ -192,18 +192,16 @@ void cleanup()
> int child_environ(void)
> {
>
> - char var[MAX_LINE_LENGTH];
> + char *child_env;
>
> /* Close read end from child */
> if ((close(pfd[0])) == -1) {
> tst_brkm(TBROK|TERRNO, cleanup, "close(pfd[0]) failed");
> }
>
> - if ((sprintf(var, "%s", getenv("TERM") ? : "")) <= 0) {
> - tst_resm(TWARN|TERRNO, "sprintf() failed");
> - }
> + child_env = getenv("TERM") ? : "";
>
> - if ((write(pfd[1], var, MAX_LINE_LENGTH)) == -1) {
> + if ((write(pfd[1], child_env, MAX_LINE_LENGTH)) == -1) {
> tst_resm(TWARN|TERRNO, "write to pipe failed");
Hmm, that one is wrong too, as you write MAX_LINE_LENGTH bytes
you write bytest __after__ the buffer.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
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 V2] clone06: set child_env to getenv directly
2012-02-23 18:29 ` Cyril Hrubis
@ 2012-02-23 18:30 ` Cyril Hrubis
[not found] ` <4F474AF7.1070901@st.com>
1 sibling, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2012-02-23 18:30 UTC (permalink / raw)
To: Salvatore CRO'; +Cc: ltp-list
Hi!
> Hmm, that one is wrong too, as you write MAX_LINE_LENGTH bytes
> you write bytest __after__ the buffer.
bytes from __after__ the buffer.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
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 V2] clone06: set child_env to getenv directly
[not found] ` <4F474AF7.1070901@st.com>
@ 2012-02-29 16:47 ` Cyril Hrubis
0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2012-02-29 16:47 UTC (permalink / raw)
To: Salvatore CRO'; +Cc: ltp-list
Hi!
> >>diff --git a/testcases/kernel/syscalls/clone/clone06.c b/testcases/kernel/syscalls/clone/clone06.c
> >>index 5db183b..50c8ef3 100644
> >>--- a/testcases/kernel/syscalls/clone/clone06.c
> >>+++ b/testcases/kernel/syscalls/clone/clone06.c
> >>@@ -192,18 +192,16 @@ void cleanup()
> >> int child_environ(void)
> >> {
> >>
> >>- char var[MAX_LINE_LENGTH];
> >>+ char *child_env;
> >>
> >> /* Close read end from child */
> >> if ((close(pfd[0])) == -1) {
> >> tst_brkm(TBROK|TERRNO, cleanup, "close(pfd[0]) failed");
> >> }
> >>
> >>- if ((sprintf(var, "%s", getenv("TERM") ? : ""))<= 0) {
> >>- tst_resm(TWARN|TERRNO, "sprintf() failed");
> >>- }
> >>+ child_env = getenv("TERM") ? : "";
> >>
> >>- if ((write(pfd[1], var, MAX_LINE_LENGTH)) == -1) {
> >>+ if ((write(pfd[1], child_env, MAX_LINE_LENGTH)) == -1) {
> >> tst_resm(TWARN|TERRNO, "write to pipe failed");
> >Hmm, that one is wrong too, as you write MAX_LINE_LENGTH bytes
> >you write bytest __after__ the buffer.
> >
> I see...
> Whould then original patch
>
> - if ((sprintf(var, "%s", getenv("TERM") ? : "")) <= 0) {
> + if ((sprintf(var, "%s", getenv("TERM") ? : "")) < 0) {
> tst_resm(TWARN|TERRNO, "sprintf() failed");
> }
>
> sounds more suitable?
> If yes you can directly apply it. Let me know if it needs me to resend it.
That one seems to be fine.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
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] clone06: legitimate zero as sprintf return value
2012-02-14 10:33 [LTP] [PATCH] clone06: legitimate zero as sprintf return value Salvatore CRO'
2012-02-14 11:03 ` [LTP] Fwd: " Salvatore CRO'
2012-02-14 11:13 ` [LTP] [PATCH V2] clone06: set child_env to getenv directly Salvatore CRO'
@ 2012-02-29 16:51 ` Cyril Hrubis
2 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2012-02-29 16:51 UTC (permalink / raw)
To: Salvatore CRO'; +Cc: ltp-list
Hi!
> - if ((sprintf(var, "%s", getenv("TERM") ? : "")) <= 0) {
> + if ((sprintf(var, "%s", getenv("TERM") ? : "")) < 0) {
> tst_resm(TWARN|TERRNO, "sprintf() failed");
Commited, thanks.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
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-02-29 16:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-14 10:33 [LTP] [PATCH] clone06: legitimate zero as sprintf return value Salvatore CRO'
2012-02-14 11:03 ` [LTP] Fwd: " Salvatore CRO'
2012-02-14 11:13 ` [LTP] [PATCH V2] clone06: set child_env to getenv directly Salvatore CRO'
2012-02-14 11:24 ` Carmelo AMOROSO
2012-02-23 18:29 ` Cyril Hrubis
2012-02-23 18:30 ` Cyril Hrubis
[not found] ` <4F474AF7.1070901@st.com>
2012-02-29 16:47 ` Cyril Hrubis
2012-02-29 16:51 ` [LTP] [PATCH] clone06: legitimate zero as sprintf return value Cyril Hrubis
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.