All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/3] kernel/syscalls/fallocate: fix array parameter degradation
@ 2015-05-06 10:18 Wei,Jiangang
  2015-05-06 10:18 ` [LTP] [PATCH 2/3] kernel/syscalls/fallocate: specify size needs check Wei,Jiangang
  2015-05-06 10:18 ` [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak Wei,Jiangang
  0 siblings, 2 replies; 18+ messages in thread
From: Wei,Jiangang @ 2015-05-06 10:18 UTC (permalink / raw)
  To: ltp-list

Using 'sizeof' on array given as function argument
returns size of a pointer, instead of the array's.
So,
It needs to pass an additional parameter size_t size
indicating the number of elements in the array.

This patch can fix it.

Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/fallocate/fallocate04.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
index 723c886..a6d1159 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate04.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
@@ -98,9 +98,8 @@ static void setup(void)
 	get_blocksize();
 }
 
-static void check_file_data(const char exp_buf[])
+static void check_file_data(const char exp_buf[], size_t size)
 {
-	size_t size = sizeof(exp_buf);
 	char rbuf[size];
 
 	tst_resm(TINFO, "reading the file, compare with expected buffer");
-- 
1.9.3


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 2/3] kernel/syscalls/fallocate: specify size needs check
  2015-05-06 10:18 [LTP] [PATCH 1/3] kernel/syscalls/fallocate: fix array parameter degradation Wei,Jiangang
@ 2015-05-06 10:18 ` Wei,Jiangang
  2015-05-06 20:42   ` Alexey Kodanev
  2015-05-06 10:18 ` [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak Wei,Jiangang
  1 sibling, 1 reply; 18+ messages in thread
From: Wei,Jiangang @ 2015-05-06 10:18 UTC (permalink / raw)
  To: ltp-list

Compare size_t size elements with file data and check
if it's excpeted.
This patch depends on bff5968.

Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/fallocate/fallocate04.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
index a6d1159..2da0bcd 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate04.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
@@ -174,7 +174,7 @@ static void test02(void)
 	fill_tst_buf(exp_buf);
 	memset(exp_buf + block_size, 0, block_size);
 
-	check_file_data(exp_buf);
+	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
 
 	tst_resm(TPASS, "test-case succeeded");
 }
@@ -214,7 +214,7 @@ static void test03(void)
 	fill_tst_buf(exp_buf);
 	memset(exp_buf + block_size - 1, 0, block_size + 2);
 
-	check_file_data(exp_buf);
+	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
 
 	tst_resm(TPASS, "test-case succeeded");
 }
@@ -250,7 +250,7 @@ static void test04(void)
 	memcpy(exp_buf, tmp_buf, block_size);
 	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
 
-	check_file_data(exp_buf);
+	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
 
 	tst_resm(TPASS, "test-case succeeded");
 }
-- 
1.9.3


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak
  2015-05-06 10:18 [LTP] [PATCH 1/3] kernel/syscalls/fallocate: fix array parameter degradation Wei,Jiangang
  2015-05-06 10:18 ` [LTP] [PATCH 2/3] kernel/syscalls/fallocate: specify size needs check Wei,Jiangang
@ 2015-05-06 10:18 ` Wei,Jiangang
  2015-05-07 14:05   ` Alexey Kodanev
  2015-05-19  3:34   ` [LTP] [PATCH] mmapstress01: Modify readbuf's type and define it to uchar_t Zeng Linggang
  1 sibling, 2 replies; 18+ messages in thread
From: Wei,Jiangang @ 2015-05-06 10:18 UTC (permalink / raw)
  To: ltp-list

Including memory and fd leak.

Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
---
 testcases/kernel/mem/mmapstress/mmapstress01.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index 0baf0e2..1db8147 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -657,6 +657,8 @@ int fileokay(char *file, uchar_t * expbuf)
 			perror("read error");
 			/***** LTP Port *****/
 			local_flag = FAILED;
+			free(readbuf);
+			close(fd);
 			anyfail();
 			/*****	**	*****/
 			return 0;
@@ -668,6 +670,8 @@ int fileokay(char *file, uchar_t * expbuf)
 				(void)fprintf(stderr, "read %d of %ld bytes\n",
 					      (i * pagesize) + cnt,
 					      (long)mapsize);
+				free(readbuf);
+				close(fd);
 				return 0;
 			}
 		}
@@ -688,10 +692,13 @@ int fileokay(char *file, uchar_t * expbuf)
 					      "(fsize %ld)\n", i, j,
 					      statbuf.st_size);
 #endif /* LARGE_FILE */
+				free(readbuf);
+				close(fd);
 				return 0;
 			}
 		}
 	}
+	free(readbuf);
 	close(fd);
 
 	return 1;
-- 
1.9.3


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/3] kernel/syscalls/fallocate: specify size needs check
  2015-05-06 10:18 ` [LTP] [PATCH 2/3] kernel/syscalls/fallocate: specify size needs check Wei,Jiangang
@ 2015-05-06 20:42   ` Alexey Kodanev
  2015-05-07  4:53     ` Wei, Jiangang
  2015-05-07  6:17     ` [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation Wei,Jiangang
  0 siblings, 2 replies; 18+ messages in thread
From: Alexey Kodanev @ 2015-05-06 20:42 UTC (permalink / raw)
  To: Wei, Jiangang, ltp-list

Hi,
On 05/06/2015 01:18 PM, Wei,Jiangang wrote:
> Compare size_t size elements with file data and check
> if it's excpeted.
> This patch depends on bff5968.
>
> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> ---
>   testcases/kernel/syscalls/fallocate/fallocate04.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
> index a6d1159..2da0bcd 100644
> --- a/testcases/kernel/syscalls/fallocate/fallocate04.c
> +++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
> @@ -174,7 +174,7 @@ static void test02(void)
>   	fill_tst_buf(exp_buf);
>   	memset(exp_buf + block_size, 0, block_size);
>   
> -	check_file_data(exp_buf);
> +	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));

Thank you for fixing it.

We could you use size variables already defined for 'exp_buf[buf_size]'.

>   
>   	tst_resm(TPASS, "test-case succeeded");
>   }
> @@ -214,7 +214,7 @@ static void test03(void)
>   	fill_tst_buf(exp_buf);
>   	memset(exp_buf + block_size - 1, 0, block_size + 2);
>   
> -	check_file_data(exp_buf);
> +	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
>   

Also buf_size variable here.

>   	tst_resm(TPASS, "test-case succeeded");
>   }
> @@ -250,7 +250,7 @@ static void test04(void)
>   	memcpy(exp_buf, tmp_buf, block_size);
>   	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
>   
> -	check_file_data(exp_buf);
> +	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
>   

'size' variable here.
>   	tst_resm(TPASS, "test-case succeeded");
>   }


Now test04 fails because I forgot to set adjacent two bytes in 'exp_buf' 
to zero in test04(), it could be fixed as follows:

@@ -250,8 +249,8 @@ static void test04(void)

         memcpy(exp_buf, tmp_buf, block_size);
         memcpy(exp_buf + block_size, tmp_buf + size, block_size);
-
-       check_file_data(exp_buf);
+       exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
+       check_file_data(exp_buf, size);

         tst_resm(TPASS, "test-case succeeded");
  }


I think it would be better to merge fallocate04 fixes in a single patch.

Thanks,
Alexey

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/3] kernel/syscalls/fallocate: specify size needs check
  2015-05-06 20:42   ` Alexey Kodanev
@ 2015-05-07  4:53     ` Wei, Jiangang
  2015-05-07  6:17     ` [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation Wei,Jiangang
  1 sibling, 0 replies; 18+ messages in thread
From: Wei, Jiangang @ 2015-05-07  4:53 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

Thanks for your comments.
I will update it.

Thanks,
wei
On Wed, 2015-05-06 at 23:42 +0300, Alexey Kodanev wrote:
> Hi,
> On 05/06/2015 01:18 PM, Wei,Jiangang wrote:
> > Compare size_t size elements with file data and check
> > if it's excpeted.
> > This patch depends on bff5968.
> >
> > Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> > ---
> >   testcases/kernel/syscalls/fallocate/fallocate04.c | 6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
> > index a6d1159..2da0bcd 100644
> > --- a/testcases/kernel/syscalls/fallocate/fallocate04.c
> > +++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
> > @@ -174,7 +174,7 @@ static void test02(void)
> >   	fill_tst_buf(exp_buf);
> >   	memset(exp_buf + block_size, 0, block_size);
> >   
> > -	check_file_data(exp_buf);
> > +	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
> 
> Thank you for fixing it.
> 
> We could you use size variables already defined for 'exp_buf[buf_size]'.
> 
> >   
> >   	tst_resm(TPASS, "test-case succeeded");
> >   }
> > @@ -214,7 +214,7 @@ static void test03(void)
> >   	fill_tst_buf(exp_buf);
> >   	memset(exp_buf + block_size - 1, 0, block_size + 2);
> >   
> > -	check_file_data(exp_buf);
> > +	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
> >   
> 
> Also buf_size variable here.
> 
> >   	tst_resm(TPASS, "test-case succeeded");
> >   }
> > @@ -250,7 +250,7 @@ static void test04(void)
> >   	memcpy(exp_buf, tmp_buf, block_size);
> >   	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
> >   
> > -	check_file_data(exp_buf);
> > +	check_file_data(exp_buf, sizeof(exp_buf)/sizeof(exp_buf[0]));
> >   
> 
> 'size' variable here.
> >   	tst_resm(TPASS, "test-case succeeded");
> >   }
> 
> 
> Now test04 fails because I forgot to set adjacent two bytes in 'exp_buf' 
> to zero in test04(), it could be fixed as follows:
> 
> @@ -250,8 +249,8 @@ static void test04(void)
> 
>          memcpy(exp_buf, tmp_buf, block_size);
>          memcpy(exp_buf + block_size, tmp_buf + size, block_size);
> -
> -       check_file_data(exp_buf);
> +       exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
> +       check_file_data(exp_buf, size);
> 
>          tst_resm(TPASS, "test-case succeeded");
>   }
> 
> 
> I think it would be better to merge fallocate04 fixes in a single patch.
> 
> Thanks,
> Alexey

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation
  2015-05-06 20:42   ` Alexey Kodanev
  2015-05-07  4:53     ` Wei, Jiangang
@ 2015-05-07  6:17     ` Wei,Jiangang
  2015-05-07  9:37       ` Alexey Kodanev
  1 sibling, 1 reply; 18+ messages in thread
From: Wei,Jiangang @ 2015-05-07  6:17 UTC (permalink / raw)
  To: ltp-list

Using 'sizeof' on array given as function argument
returns size of a pointer, instead of the array's.
So,
It needs to pass an additional parameter size_t size
indicating the number of elements in the array.

Besides above,
Set adjacent two bytes in 'exp_buf' to zero in test04().

Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/fallocate/fallocate04.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
index 723c886..911bbe8 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate04.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
@@ -98,9 +98,8 @@ static void setup(void)
 	get_blocksize();
 }
 
-static void check_file_data(const char exp_buf[])
+static void check_file_data(const char exp_buf[], size_t size)
 {
-	size_t size = sizeof(exp_buf);
 	char rbuf[size];
 
 	tst_resm(TINFO, "reading the file, compare with expected buffer");
@@ -175,7 +174,7 @@ static void test02(void)
 	fill_tst_buf(exp_buf);
 	memset(exp_buf + block_size, 0, block_size);
 
-	check_file_data(exp_buf);
+	check_file_data(exp_buf, buf_size);
 
 	tst_resm(TPASS, "test-case succeeded");
 }
@@ -215,7 +214,7 @@ static void test03(void)
 	fill_tst_buf(exp_buf);
 	memset(exp_buf + block_size - 1, 0, block_size + 2);
 
-	check_file_data(exp_buf);
+	check_file_data(exp_buf, buf_size);
 
 	tst_resm(TPASS, "test-case succeeded");
 }
@@ -251,7 +250,8 @@ static void test04(void)
 	memcpy(exp_buf, tmp_buf, block_size);
 	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
 
-	check_file_data(exp_buf);
+	exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
+	check_file_data(exp_buf, size);
 
 	tst_resm(TPASS, "test-case succeeded");
 }
-- 
1.9.3


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation
  2015-05-07  6:17     ` [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation Wei,Jiangang
@ 2015-05-07  9:37       ` Alexey Kodanev
  2015-05-07  9:54         ` Wei, Jiangang
  0 siblings, 1 reply; 18+ messages in thread
From: Alexey Kodanev @ 2015-05-07  9:37 UTC (permalink / raw)
  To: Wei, Jiangang, ltp-list

Hi,
On 05/07/2015 09:17 AM, Wei,Jiangang wrote:
> Using 'sizeof' on array given as function argument
> returns size of a pointer, instead of the array's.
> So,
> It needs to pass an additional parameter size_t size
> indicating the number of elements in the array.
>
> Besides above,
> Set adjacent two bytes in 'exp_buf' to zero in test04().
>
> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> ---
>   testcases/kernel/syscalls/fallocate/fallocate04.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
> index 723c886..911bbe8 100644
> --- a/testcases/kernel/syscalls/fallocate/fallocate04.c
> +++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
> @@ -98,9 +98,8 @@ static void setup(void)
>   	get_blocksize();
>   }
>   
> -static void check_file_data(const char exp_buf[])
> +static void check_file_data(const char exp_buf[], size_t size)
>   {
> -	size_t size = sizeof(exp_buf);
>   	char rbuf[size];
>   
>   	tst_resm(TINFO, "reading the file, compare with expected buffer");
> @@ -175,7 +174,7 @@ static void test02(void)
>   	fill_tst_buf(exp_buf);
>   	memset(exp_buf + block_size, 0, block_size);
>   
> -	check_file_data(exp_buf);
> +	check_file_data(exp_buf, buf_size);
>   
>   	tst_resm(TPASS, "test-case succeeded");
>   }
> @@ -215,7 +214,7 @@ static void test03(void)
>   	fill_tst_buf(exp_buf);
>   	memset(exp_buf + block_size - 1, 0, block_size + 2);
>   
> -	check_file_data(exp_buf);
> +	check_file_data(exp_buf, buf_size);
>   
>   	tst_resm(TPASS, "test-case succeeded");
>   }
> @@ -251,7 +250,8 @@ static void test04(void)
>   	memcpy(exp_buf, tmp_buf, block_size);
>   	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
>   
> -	check_file_data(exp_buf);
> +	exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
> +	check_file_data(exp_buf, size);
>   
>   	tst_resm(TPASS, "test-case succeeded");
>   }

Patch applied, thank you!

Best regards,
Alexey



------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation
  2015-05-07  9:37       ` Alexey Kodanev
@ 2015-05-07  9:54         ` Wei, Jiangang
  2015-05-12  5:43           ` Wanlong Gao
  0 siblings, 1 reply; 18+ messages in thread
From: Wei, Jiangang @ 2015-05-07  9:54 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

On Thu, 2015-05-07 at 12:37 +0300, Alexey Kodanev wrote:
> Hi,
> On 05/07/2015 09:17 AM, Wei,Jiangang wrote:
> > Using 'sizeof' on array given as function argument
> > returns size of a pointer, instead of the array's.
> > So,
> > It needs to pass an additional parameter size_t size
> > indicating the number of elements in the array.
> >
> > Besides above,
> > Set adjacent two bytes in 'exp_buf' to zero in test04().
> >
> > Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> > ---
> >   testcases/kernel/syscalls/fallocate/fallocate04.c | 10 +++++-----
> >   1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
> > index 723c886..911bbe8 100644
> > --- a/testcases/kernel/syscalls/fallocate/fallocate04.c
> > +++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
> > @@ -98,9 +98,8 @@ static void setup(void)
> >   	get_blocksize();
> >   }
> >   
> > -static void check_file_data(const char exp_buf[])
> > +static void check_file_data(const char exp_buf[], size_t size)
> >   {
> > -	size_t size = sizeof(exp_buf);
> >   	char rbuf[size];
> >   
> >   	tst_resm(TINFO, "reading the file, compare with expected buffer");
> > @@ -175,7 +174,7 @@ static void test02(void)
> >   	fill_tst_buf(exp_buf);
> >   	memset(exp_buf + block_size, 0, block_size);
> >   
> > -	check_file_data(exp_buf);
> > +	check_file_data(exp_buf, buf_size);
> >   
> >   	tst_resm(TPASS, "test-case succeeded");
> >   }
> > @@ -215,7 +214,7 @@ static void test03(void)
> >   	fill_tst_buf(exp_buf);
> >   	memset(exp_buf + block_size - 1, 0, block_size + 2);
> >   
> > -	check_file_data(exp_buf);
> > +	check_file_data(exp_buf, buf_size);
> >   
> >   	tst_resm(TPASS, "test-case succeeded");
> >   }
> > @@ -251,7 +250,8 @@ static void test04(void)
> >   	memcpy(exp_buf, tmp_buf, block_size);
> >   	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
> >   
> > -	check_file_data(exp_buf);
> > +	exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
> > +	check_file_data(exp_buf, size);
> >   
> >   	tst_resm(TPASS, "test-case succeeded");
> >   }
> 
> Patch applied, thank you!

Thank you for your feedback so quickly.
Do you have noticed the other commit?
 ->[PATCH 3/3] kernel/mem/mmapstress: fix resource leak

I guess it might have been ignored...

Thanks again,
Wei
> 
> Best regards,
> Alexey
> 
> 

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak
  2015-05-06 10:18 ` [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak Wei,Jiangang
@ 2015-05-07 14:05   ` Alexey Kodanev
  2015-05-08  6:42     ` Wei, Jiangang
  2015-05-08  6:47     ` [LTP] [PATCH v2] " Wei,Jiangang
  2015-05-19  3:34   ` [LTP] [PATCH] mmapstress01: Modify readbuf's type and define it to uchar_t Zeng Linggang
  1 sibling, 2 replies; 18+ messages in thread
From: Alexey Kodanev @ 2015-05-07 14:05 UTC (permalink / raw)
  To: Wei, Jiangang, ltp-list

On 05/06/2015 01:18 PM, Wei,Jiangang wrote:
> Including memory and fd leak.
>
> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> ---
>   testcases/kernel/mem/mmapstress/mmapstress01.c | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
> index 0baf0e2..1db8147 100644
> --- a/testcases/kernel/mem/mmapstress/mmapstress01.c
> +++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
> @@ -657,6 +657,8 @@ int fileokay(char *file, uchar_t * expbuf)
>   			perror("read error");
>   			/***** LTP Port *****/
>   			local_flag = FAILED;
> +			free(readbuf);

We could allocate readbuf on the stack... readbuf[pagesize] so free() 
not needed.

> +			close(fd);
>   			anyfail();

anyfail() calls tst_brkm() - the program terminates and closes fd.

>   			/*****	**	*****/
>   			return 0;
> @@ -668,6 +670,8 @@ int fileokay(char *file, uchar_t * expbuf)
>   				(void)fprintf(stderr, "read %d of %ld bytes\n",
>   					      (i * pagesize) + cnt,
>   					      (long)mapsize);
> +				free(readbuf);
> +				close(fd);
>   				return 0;
>   			}
>   		}
> @@ -688,10 +692,13 @@ int fileokay(char *file, uchar_t * expbuf)
>   					      "(fsize %ld)\n", i, j,
>   					      statbuf.st_size);
>   #endif /* LARGE_FILE */
> +				free(readbuf);
> +				close(fd);
>   				return 0;

In both above cases it'll call anyfail() after checking fileokay()'s 
return value.
If it seems not obvious we can close 'fd' here and it'd be better to use 
SAFE_CLOSE() macro from safe_macros.h.

>   			}
>   		}
>   	}
> +	free(readbuf);
>   	close(fd);
>   
>   	return 1;

Thanks,
Alexey

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak
  2015-05-07 14:05   ` Alexey Kodanev
@ 2015-05-08  6:42     ` Wei, Jiangang
  2015-05-12  9:12       ` Cyril Hrubis
  2015-05-13 12:03       ` Alexey Kodanev
  2015-05-08  6:47     ` [LTP] [PATCH v2] " Wei,Jiangang
  1 sibling, 2 replies; 18+ messages in thread
From: Wei, Jiangang @ 2015-05-08  6:42 UTC (permalink / raw)
  To: alexey.kodanev; +Cc: ltp-list

On Thu, 2015-05-07 at 17:05 +0300, Alexey Kodanev wrote:
> On 05/06/2015 01:18 PM, Wei,Jiangang wrote:
> > Including memory and fd leak.
> >
> > Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> > ---
> >   testcases/kernel/mem/mmapstress/mmapstress01.c | 7 +++++++
> >   1 file changed, 7 insertions(+)
> >
> > diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
> > index 0baf0e2..1db8147 100644
> > --- a/testcases/kernel/mem/mmapstress/mmapstress01.c
> > +++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
> > @@ -657,6 +657,8 @@ int fileokay(char *file, uchar_t * expbuf)
> >   			perror("read error");
> >   			/***** LTP Port *****/
> >   			local_flag = FAILED;
> > +			free(readbuf);
> 
> We could allocate readbuf on the stack... readbuf[pagesize] so free() 
> not needed.
Thanks for your comments.
Yes, That's right.
I accept it.
> 
> > +			close(fd);
> >   			anyfail();
> 
> anyfail() calls tst_brkm() - the program terminates and closes fd.
> 
> >   			/*****	**	*****/
> >   			return 0;
> > @@ -668,6 +670,8 @@ int fileokay(char *file, uchar_t * expbuf)
> >   				(void)fprintf(stderr, "read %d of %ld bytes\n",
> >   					      (i * pagesize) + cnt,
> >   					      (long)mapsize);
> > +				free(readbuf);
> > +				close(fd);
> >   				return 0;
> >   			}
> >   		}
> > @@ -688,10 +692,13 @@ int fileokay(char *file, uchar_t * expbuf)
> >   					      "(fsize %ld)\n", i, j,
> >   					      statbuf.st_size);
> >   #endif /* LARGE_FILE */
> > +				free(readbuf);
> > +				close(fd);
> >   				return 0;
> 
> In both above cases it'll call anyfail() after checking fileokay()'s 
> return value.
> If it seems not obvious we can close 'fd' here and it'd be better to use 
> SAFE_CLOSE() macro from safe_macros.h.
There's no cleanup function for SAFE_CLOSE().
so,
close() is the same as SAFE_CLOSE(NULL, fd).

And close(fd) had been used at mmapstress01.c.
if i adopt SAFE_CLOSE(NULL, fd),
It looks a bit odd...

Thanks,
Wei
> 
> >   			}
> >   		}
> >   	}
> > +	free(readbuf);
> >   	close(fd);
> >   
> >   	return 1;
> 
> Thanks,
> Alexey

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH v2] kernel/mem/mmapstress: fix resource leak
  2015-05-07 14:05   ` Alexey Kodanev
  2015-05-08  6:42     ` Wei, Jiangang
@ 2015-05-08  6:47     ` Wei,Jiangang
  1 sibling, 0 replies; 18+ messages in thread
From: Wei,Jiangang @ 2015-05-08  6:47 UTC (permalink / raw)
  To: ltp-list

* Avoid memory leak by allocate readbuf on the stack,
  not by malloc.

* close file descriptor explicitly before return.

Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
---
 testcases/kernel/mem/mmapstress/mmapstress01.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index 0baf0e2..ed1466a 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -602,9 +602,9 @@ int fileokay(char *file, uchar_t * expbuf)
 	struct stat statbuf;
 #endif /* LARGE_FILE */
 	size_t mapsize;
-	uchar_t *readbuf;
 	unsigned mappages;
 	unsigned pagesize = sysconf(_SC_PAGE_SIZE);
+	char readbuf[pagesize];
 	int fd;
 	int cnt;
 	unsigned i, j;
@@ -641,7 +641,6 @@ int fileokay(char *file, uchar_t * expbuf)
 		perror("lseek");
 		anyfail();
 	}
-	readbuf = malloc(pagesize);
 
 	if (statbuf.st_size - sparseoffset > SIZE_MAX) {
 		fprintf(stderr, "size_t overflow when setting up map\n");
@@ -668,6 +667,7 @@ int fileokay(char *file, uchar_t * expbuf)
 				(void)fprintf(stderr, "read %d of %ld bytes\n",
 					      (i * pagesize) + cnt,
 					      (long)mapsize);
+				close(fd);
 				return 0;
 			}
 		}
@@ -688,6 +688,7 @@ int fileokay(char *file, uchar_t * expbuf)
 					      "(fsize %ld)\n", i, j,
 					      statbuf.st_size);
 #endif /* LARGE_FILE */
+				close(fd);
 				return 0;
 			}
 		}
-- 
1.9.3


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation
  2015-05-07  9:54         ` Wei, Jiangang
@ 2015-05-12  5:43           ` Wanlong Gao
  2015-05-12  5:44             ` Wanlong Gao
  0 siblings, 1 reply; 18+ messages in thread
From: Wanlong Gao @ 2015-05-12  5:43 UTC (permalink / raw)
  To: Wei, Jiangang, alexey.kodanev; +Cc: ltp-list

On 05/07/2015 05:54 PM, Wei, Jiangang wrote:
> On Thu, 2015-05-07 at 12:37 +0300, Alexey Kodanev wrote:
>> Hi,
>> On 05/07/2015 09:17 AM, Wei,Jiangang wrote:
>>> Using 'sizeof' on array given as function argument
>>> returns size of a pointer, instead of the array's.
>>> So,
>>> It needs to pass an additional parameter size_t size
>>> indicating the number of elements in the array.
>>>
>>> Besides above,
>>> Set adjacent two bytes in 'exp_buf' to zero in test04().
>>>
>>> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
>>> ---
>>>   testcases/kernel/syscalls/fallocate/fallocate04.c | 10 +++++-----
>>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
>>> index 723c886..911bbe8 100644
>>> --- a/testcases/kernel/syscalls/fallocate/fallocate04.c
>>> +++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
>>> @@ -98,9 +98,8 @@ static void setup(void)
>>>   	get_blocksize();
>>>   }
>>>   
>>> -static void check_file_data(const char exp_buf[])
>>> +static void check_file_data(const char exp_buf[], size_t size)
>>>   {
>>> -	size_t size = sizeof(exp_buf);
>>>   	char rbuf[size];
>>>   
>>>   	tst_resm(TINFO, "reading the file, compare with expected buffer");
>>> @@ -175,7 +174,7 @@ static void test02(void)
>>>   	fill_tst_buf(exp_buf);
>>>   	memset(exp_buf + block_size, 0, block_size);
>>>   
>>> -	check_file_data(exp_buf);
>>> +	check_file_data(exp_buf, buf_size);
>>>   
>>>   	tst_resm(TPASS, "test-case succeeded");
>>>   }
>>> @@ -215,7 +214,7 @@ static void test03(void)
>>>   	fill_tst_buf(exp_buf);
>>>   	memset(exp_buf + block_size - 1, 0, block_size + 2);
>>>   
>>> -	check_file_data(exp_buf);
>>> +	check_file_data(exp_buf, buf_size);
>>>   
>>>   	tst_resm(TPASS, "test-case succeeded");
>>>   }
>>> @@ -251,7 +250,8 @@ static void test04(void)
>>>   	memcpy(exp_buf, tmp_buf, block_size);
>>>   	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
>>>   
>>> -	check_file_data(exp_buf);
>>> +	exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
>>> +	check_file_data(exp_buf, size);
>>>   
>>>   	tst_resm(TPASS, "test-case succeeded");
>>>   }
>>
>> Patch applied, thank you!
> 
> Thank you for your feedback so quickly.
> Do you have noticed the other commit?
>  ->[PATCH 3/3] kernel/mem/mmapstress: fix resource leak
> 
> I guess it might have been ignored...

It's a bit messy, would you repost your patches which were
not applied to make things more clearly?

Thanks,
Wanlong Gao

> 
> Thanks again,
> Wei
>>
>> Best regards,
>> Alexey
>>
>>
> 
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud 
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> .
> 


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation
  2015-05-12  5:43           ` Wanlong Gao
@ 2015-05-12  5:44             ` Wanlong Gao
  2015-05-12  5:52               ` Wei, Jiangang
  0 siblings, 1 reply; 18+ messages in thread
From: Wanlong Gao @ 2015-05-12  5:44 UTC (permalink / raw)
  To: Wei, Jiangang, alexey.kodanev; +Cc: ltp-list

On 05/12/2015 01:43 PM, Wanlong Gao wrote:
> On 05/07/2015 05:54 PM, Wei, Jiangang wrote:
>> On Thu, 2015-05-07 at 12:37 +0300, Alexey Kodanev wrote:
>>> Hi,
>>> On 05/07/2015 09:17 AM, Wei,Jiangang wrote:
>>>> Using 'sizeof' on array given as function argument
>>>> returns size of a pointer, instead of the array's.
>>>> So,
>>>> It needs to pass an additional parameter size_t size
>>>> indicating the number of elements in the array.
>>>>
>>>> Besides above,
>>>> Set adjacent two bytes in 'exp_buf' to zero in test04().
>>>>
>>>> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
>>>> ---
>>>>   testcases/kernel/syscalls/fallocate/fallocate04.c | 10 +++++-----
>>>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
>>>> index 723c886..911bbe8 100644
>>>> --- a/testcases/kernel/syscalls/fallocate/fallocate04.c
>>>> +++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
>>>> @@ -98,9 +98,8 @@ static void setup(void)
>>>>   	get_blocksize();
>>>>   }
>>>>   
>>>> -static void check_file_data(const char exp_buf[])
>>>> +static void check_file_data(const char exp_buf[], size_t size)
>>>>   {
>>>> -	size_t size = sizeof(exp_buf);
>>>>   	char rbuf[size];
>>>>   
>>>>   	tst_resm(TINFO, "reading the file, compare with expected buffer");
>>>> @@ -175,7 +174,7 @@ static void test02(void)
>>>>   	fill_tst_buf(exp_buf);
>>>>   	memset(exp_buf + block_size, 0, block_size);
>>>>   
>>>> -	check_file_data(exp_buf);
>>>> +	check_file_data(exp_buf, buf_size);
>>>>   
>>>>   	tst_resm(TPASS, "test-case succeeded");
>>>>   }
>>>> @@ -215,7 +214,7 @@ static void test03(void)
>>>>   	fill_tst_buf(exp_buf);
>>>>   	memset(exp_buf + block_size - 1, 0, block_size + 2);
>>>>   
>>>> -	check_file_data(exp_buf);
>>>> +	check_file_data(exp_buf, buf_size);
>>>>   
>>>>   	tst_resm(TPASS, "test-case succeeded");
>>>>   }
>>>> @@ -251,7 +250,8 @@ static void test04(void)
>>>>   	memcpy(exp_buf, tmp_buf, block_size);
>>>>   	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
>>>>   
>>>> -	check_file_data(exp_buf);
>>>> +	exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
>>>> +	check_file_data(exp_buf, size);
>>>>   
>>>>   	tst_resm(TPASS, "test-case succeeded");
>>>>   }
>>>
>>> Patch applied, thank you!
>>
>> Thank you for your feedback so quickly.
>> Do you have noticed the other commit?
>>  ->[PATCH 3/3] kernel/mem/mmapstress: fix resource leak
>>
>> I guess it might have been ignored...
> 
> It's a bit messy, would you repost your patches which were
> not applied to make things more clearly?

And start a new mail thread.

Thanks,
Wanlong Gao

> 
> Thanks,
> Wanlong Gao
> 
>>
>> Thanks again,
>> Wei
>>>
>>> Best regards,
>>> Alexey
>>>
>>>
>>
>> ------------------------------------------------------------------------------
>> One dashboard for servers and applications across Physical-Virtual-Cloud 
>> Widest out-of-the-box monitoring support with 50+ applications
>> Performance metrics, stats and reports that give you Actionable Insights
>> Deep dive visibility with transaction tracing using APM Insight.
>> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>> _______________________________________________
>> Ltp-list mailing list
>> Ltp-list@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/ltp-list
>> .
>>
> 
> .
> 


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation
  2015-05-12  5:44             ` Wanlong Gao
@ 2015-05-12  5:52               ` Wei, Jiangang
  0 siblings, 0 replies; 18+ messages in thread
From: Wei, Jiangang @ 2015-05-12  5:52 UTC (permalink / raw)
  To: Gao, Wanlong; +Cc: ltp-list

On Tue, 2015-05-12 at 13:44 +0800, Wanlong Gao wrote:
> On 05/12/2015 01:43 PM, Wanlong Gao wrote:
> > On 05/07/2015 05:54 PM, Wei, Jiangang wrote:
> >> On Thu, 2015-05-07 at 12:37 +0300, Alexey Kodanev wrote:
> >>> Hi,
> >>> On 05/07/2015 09:17 AM, Wei,Jiangang wrote:
> >>>> Using 'sizeof' on array given as function argument
> >>>> returns size of a pointer, instead of the array's.
> >>>> So,
> >>>> It needs to pass an additional parameter size_t size
> >>>> indicating the number of elements in the array.
> >>>>
> >>>> Besides above,
> >>>> Set adjacent two bytes in 'exp_buf' to zero in test04().
> >>>>
> >>>> Signed-off-by: Wei,Jiangang <weijg.fnst@cn.fujitsu.com>
> >>>> ---
> >>>>   testcases/kernel/syscalls/fallocate/fallocate04.c | 10 +++++-----
> >>>>   1 file changed, 5 insertions(+), 5 deletions(-)
> >>>>
> >>>> diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
> >>>> index 723c886..911bbe8 100644
> >>>> --- a/testcases/kernel/syscalls/fallocate/fallocate04.c
> >>>> +++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
> >>>> @@ -98,9 +98,8 @@ static void setup(void)
> >>>>   	get_blocksize();
> >>>>   }
> >>>>   
> >>>> -static void check_file_data(const char exp_buf[])
> >>>> +static void check_file_data(const char exp_buf[], size_t size)
> >>>>   {
> >>>> -	size_t size = sizeof(exp_buf);
> >>>>   	char rbuf[size];
> >>>>   
> >>>>   	tst_resm(TINFO, "reading the file, compare with expected buffer");
> >>>> @@ -175,7 +174,7 @@ static void test02(void)
> >>>>   	fill_tst_buf(exp_buf);
> >>>>   	memset(exp_buf + block_size, 0, block_size);
> >>>>   
> >>>> -	check_file_data(exp_buf);
> >>>> +	check_file_data(exp_buf, buf_size);
> >>>>   
> >>>>   	tst_resm(TPASS, "test-case succeeded");
> >>>>   }
> >>>> @@ -215,7 +214,7 @@ static void test03(void)
> >>>>   	fill_tst_buf(exp_buf);
> >>>>   	memset(exp_buf + block_size - 1, 0, block_size + 2);
> >>>>   
> >>>> -	check_file_data(exp_buf);
> >>>> +	check_file_data(exp_buf, buf_size);
> >>>>   
> >>>>   	tst_resm(TPASS, "test-case succeeded");
> >>>>   }
> >>>> @@ -251,7 +250,8 @@ static void test04(void)
> >>>>   	memcpy(exp_buf, tmp_buf, block_size);
> >>>>   	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
> >>>>   
> >>>> -	check_file_data(exp_buf);
> >>>> +	exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
> >>>> +	check_file_data(exp_buf, size);
> >>>>   
> >>>>   	tst_resm(TPASS, "test-case succeeded");
> >>>>   }
> >>>
> >>> Patch applied, thank you!
> >>
> >> Thank you for your feedback so quickly.
> >> Do you have noticed the other commit?
> >>  ->[PATCH 3/3] kernel/mem/mmapstress: fix resource leak
> >>
> >> I guess it might have been ignored...
> > 
> > It's a bit messy, would you repost your patches which were
> > not applied to make things more clearly?
> 
> And start a new mail thread.
OK, I got it.

Regards,
Wei
> 
> Thanks,
> Wanlong Gao
> 
> > 
> > Thanks,
> > Wanlong Gao
> > 
> >>
> >> Thanks again,
> >> Wei
> >>>
> >>> Best regards,
> >>> Alexey
> >>>
> >>>
> >>
> >> ------------------------------------------------------------------------------
> >> One dashboard for servers and applications across Physical-Virtual-Cloud 
> >> Widest out-of-the-box monitoring support with 50+ applications
> >> Performance metrics, stats and reports that give you Actionable Insights
> >> Deep dive visibility with transaction tracing using APM Insight.
> >> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> >> _______________________________________________
> >> Ltp-list mailing list
> >> Ltp-list@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/ltp-list
> >> .
> >>
> > 
> > .
> > 
> 

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak
  2015-05-08  6:42     ` Wei, Jiangang
@ 2015-05-12  9:12       ` Cyril Hrubis
  2015-05-13 12:03       ` Alexey Kodanev
  1 sibling, 0 replies; 18+ messages in thread
From: Cyril Hrubis @ 2015-05-12  9:12 UTC (permalink / raw)
  To: Wei, Jiangang; +Cc: ltp-list

Hi!
> There's no cleanup function for SAFE_CLOSE(). so,
> close() is the same as SAFE_CLOSE(NULL, fd).

FYI, there is a difference between plain close() and
SAFE_CLOSE(NULL, fd). The latter checks the return value
from close(). Have a look at lib/safe_macros.c.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak
  2015-05-08  6:42     ` Wei, Jiangang
  2015-05-12  9:12       ` Cyril Hrubis
@ 2015-05-13 12:03       ` Alexey Kodanev
  1 sibling, 0 replies; 18+ messages in thread
From: Alexey Kodanev @ 2015-05-13 12:03 UTC (permalink / raw)
  To: Wei, Jiangang; +Cc: ltp-list

Hi,
On 05/08/2015 09:42 AM, Wei, Jiangang wrote:
> On Thu, 2015-05-07 at 17:05 +0300, Alexey Kodanev wrote:
>
>> In both above cases it'll call anyfail() after checking fileokay()'s
>> return value.
>> If it seems not obvious we can close 'fd' here and it'd be better to use
>> SAFE_CLOSE() macro from safe_macros.h.
> There's no cleanup function for SAFE_CLOSE().
> so,
> close() is the same as SAFE_CLOSE(NULL, fd).

tst_brkm() is using tst_rmdir() as a cleanup function.


Best regards,
Alexey


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH] mmapstress01: Modify readbuf's type and define it to uchar_t
  2015-05-06 10:18 ` [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak Wei,Jiangang
  2015-05-07 14:05   ` Alexey Kodanev
@ 2015-05-19  3:34   ` Zeng Linggang
  2015-05-19  9:23     ` Jan Stancek
  1 sibling, 1 reply; 18+ messages in thread
From: Zeng Linggang @ 2015-05-19  3:34 UTC (permalink / raw)
  To: Wei,Jiangang; +Cc: ltp-list

readbuf is defined to char. That is different with the previous
defined. If readbuf's value is more than 127, that would be regarded
as negative number. And expbuf is uchar_t, the value is always
nonegative. That will make the test fail because the different data
type.

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
---
 testcases/kernel/mem/mmapstress/mmapstress01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index ed1466a..81566f2 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -604,7 +604,7 @@ int fileokay(char *file, uchar_t * expbuf)
 	size_t mapsize;
 	unsigned mappages;
 	unsigned pagesize = sysconf(_SC_PAGE_SIZE);
-	char readbuf[pagesize];
+	uchar_t readbuf[pagesize];
 	int fd;
 	int cnt;
 	unsigned i, j;
-- 
1.9.3




------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] mmapstress01: Modify readbuf's type and define it to uchar_t
  2015-05-19  3:34   ` [LTP] [PATCH] mmapstress01: Modify readbuf's type and define it to uchar_t Zeng Linggang
@ 2015-05-19  9:23     ` Jan Stancek
  0 siblings, 0 replies; 18+ messages in thread
From: Jan Stancek @ 2015-05-19  9:23 UTC (permalink / raw)
  To: Zeng Linggang; +Cc: ltp-list



----- Original Message -----
> From: "Zeng Linggang" <zenglg.jy@cn.fujitsu.com>
> To: "Jiangang Wei" <weijg.fnst@cn.fujitsu.com>
> Cc: ltp-list@lists.sourceforge.net
> Sent: Tuesday, 19 May, 2015 5:34:01 AM
> Subject: [LTP] [PATCH] mmapstress01: Modify readbuf's type and define it to	uchar_t
> 
> readbuf is defined to char. That is different with the previous
> defined. If readbuf's value is more than 127, that would be regarded
> as negative number. And expbuf is uchar_t, the value is always
> nonegative. That will make the test fail because the different data
> type.
> 
> Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>

Applied.

Regards,
Jan

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2015-05-19  9:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06 10:18 [LTP] [PATCH 1/3] kernel/syscalls/fallocate: fix array parameter degradation Wei,Jiangang
2015-05-06 10:18 ` [LTP] [PATCH 2/3] kernel/syscalls/fallocate: specify size needs check Wei,Jiangang
2015-05-06 20:42   ` Alexey Kodanev
2015-05-07  4:53     ` Wei, Jiangang
2015-05-07  6:17     ` [LTP] [PATCH v2] kernel/syscalls/fallocate: fix array parameter degradation Wei,Jiangang
2015-05-07  9:37       ` Alexey Kodanev
2015-05-07  9:54         ` Wei, Jiangang
2015-05-12  5:43           ` Wanlong Gao
2015-05-12  5:44             ` Wanlong Gao
2015-05-12  5:52               ` Wei, Jiangang
2015-05-06 10:18 ` [LTP] [PATCH 3/3] kernel/mem/mmapstress: fix resource leak Wei,Jiangang
2015-05-07 14:05   ` Alexey Kodanev
2015-05-08  6:42     ` Wei, Jiangang
2015-05-12  9:12       ` Cyril Hrubis
2015-05-13 12:03       ` Alexey Kodanev
2015-05-08  6:47     ` [LTP] [PATCH v2] " Wei,Jiangang
2015-05-19  3:34   ` [LTP] [PATCH] mmapstress01: Modify readbuf's type and define it to uchar_t Zeng Linggang
2015-05-19  9:23     ` Jan Stancek

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.