linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] selftest mm/mseal compile warning
@ 2024-04-19  3:43 jeffxu
  2024-04-19  3:43 ` [PATCH 1/1] selftest mm/mseal: fix " jeffxu
  0 siblings, 1 reply; 5+ messages in thread
From: jeffxu @ 2024-04-19  3:43 UTC (permalink / raw)
  To: akpm; +Cc: jeffxu, linux-kselftest, linux-mm, Jeff Xu

From: Jeff Xu <jeffxu@chromium.org>

fix compile warning reported by test robot [1]

Please apply on top of patch titled:
"selftest mm/mseal: style change"
(which already in mm-unstable)

[1] https://lore.kernel.org/all/202404190226.OfJOewV8-lkp@intel.com/

Thanks!
-Jeff


Jeff Xu (1):
  selftest mm/mseal: fix compile warning

 tools/testing/selftests/mm/mseal_test.c | 3 +--
 tools/testing/selftests/mm/seal_elf.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

-- 
2.44.0.769.g3c40516874-goog



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

* [PATCH 1/1] selftest mm/mseal: fix compile warning
  2024-04-19  3:43 [PATCH 0/1] selftest mm/mseal compile warning jeffxu
@ 2024-04-19  3:43 ` jeffxu
  2024-04-19 16:27   ` Muhammad Usama Anjum
  2024-04-19 16:42   ` Pedro Falcato
  0 siblings, 2 replies; 5+ messages in thread
From: jeffxu @ 2024-04-19  3:43 UTC (permalink / raw)
  To: akpm; +Cc: jeffxu, linux-kselftest, linux-mm, Jeff Xu, kernel test robot

From: Jeff Xu <jeffxu@chromium.org>

fix compile warning reported by test robot

Signed-off-by: Jeff Xu <jeffxu@chromium.org>
Reported-by: kernel test robot <yujie.liu@intel.com>
Closes: https://lore.kernel.org/r/202404190226.OfJOewV8-lkp@intel.com/
---
 tools/testing/selftests/mm/mseal_test.c | 3 +--
 tools/testing/selftests/mm/seal_elf.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
index 4a326334726d..35cdae93e580 100644
--- a/tools/testing/selftests/mm/mseal_test.c
+++ b/tools/testing/selftests/mm/mseal_test.c
@@ -79,7 +79,7 @@ static unsigned long get_vma_size(void *addr, int *prot)
 		return 0;
 
 	while (fgets(line, sizeof(line), maps)) {
-		if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, &protstr) == 3) {
+		if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, (char *) &protstr) == 3) {
 			if (addr_start == (uintptr_t) addr) {
 				size = addr_end - addr_start;
 				if (protstr[0] == 'r')
@@ -208,7 +208,6 @@ static u64 set_pkey_bits(u64 reg, int pkey, u64 flags)
 
 static void set_pkey(int pkey, unsigned long pkey_value)
 {
-	unsigned long mask = (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE);
 	u64 new_pkey_reg;
 
 	new_pkey_reg = set_pkey_bits(__read_pkey_reg(), pkey, pkey_value);
diff --git a/tools/testing/selftests/mm/seal_elf.c b/tools/testing/selftests/mm/seal_elf.c
index 7143dc4f1b10..b7e72f9804f8 100644
--- a/tools/testing/selftests/mm/seal_elf.c
+++ b/tools/testing/selftests/mm/seal_elf.c
@@ -105,7 +105,6 @@ static void test_seal_elf(void)
 	int ret;
 	FILE *maps;
 	char line[512];
-	int size = 0;
 	uintptr_t  addr_start, addr_end;
 	char prot[5];
 	char filename[256];
@@ -136,7 +135,7 @@ static void test_seal_elf(void)
 	 */
 	while (fgets(line, sizeof(line), maps)) {
 		if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*u %255[^\n]",
-			&addr_start, &addr_end, &prot, &filename) == 4) {
+			&addr_start, &addr_end, (char *)&prot, (char *)&filename) == 4) {
 			if (strlen(filename)) {
 				/*
 				 * seal the mapping if read only.
-- 
2.44.0.769.g3c40516874-goog



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

* Re: [PATCH 1/1] selftest mm/mseal: fix compile warning
  2024-04-19  3:43 ` [PATCH 1/1] selftest mm/mseal: fix " jeffxu
@ 2024-04-19 16:27   ` Muhammad Usama Anjum
  2024-04-19 16:42   ` Pedro Falcato
  1 sibling, 0 replies; 5+ messages in thread
From: Muhammad Usama Anjum @ 2024-04-19 16:27 UTC (permalink / raw)
  To: jeffxu, akpm
  Cc: Muhammad Usama Anjum, jeffxu, linux-kselftest, linux-mm,
	kernel test robot

On 4/19/24 8:43 AM, jeffxu@chromium.org wrote:
> From: Jeff Xu <jeffxu@chromium.org>
> 
> fix compile warning reported by test robot
> 
> Signed-off-by: Jeff Xu <jeffxu@chromium.org>
> Reported-by: kernel test robot <yujie.liu@intel.com>
> Closes: https://lore.kernel.org/r/202404190226.OfJOewV8-lkp@intel.com/
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
>  tools/testing/selftests/mm/mseal_test.c | 3 +--
>  tools/testing/selftests/mm/seal_elf.c   | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
> index 4a326334726d..35cdae93e580 100644
> --- a/tools/testing/selftests/mm/mseal_test.c
> +++ b/tools/testing/selftests/mm/mseal_test.c
> @@ -79,7 +79,7 @@ static unsigned long get_vma_size(void *addr, int *prot)
>  		return 0;
>  
>  	while (fgets(line, sizeof(line), maps)) {
> -		if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, &protstr) == 3) {
> +		if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, (char *) &protstr) == 3) {
>  			if (addr_start == (uintptr_t) addr) {
>  				size = addr_end - addr_start;
>  				if (protstr[0] == 'r')
> @@ -208,7 +208,6 @@ static u64 set_pkey_bits(u64 reg, int pkey, u64 flags)
>  
>  static void set_pkey(int pkey, unsigned long pkey_value)
>  {
> -	unsigned long mask = (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE);
>  	u64 new_pkey_reg;
>  
>  	new_pkey_reg = set_pkey_bits(__read_pkey_reg(), pkey, pkey_value);
> diff --git a/tools/testing/selftests/mm/seal_elf.c b/tools/testing/selftests/mm/seal_elf.c
> index 7143dc4f1b10..b7e72f9804f8 100644
> --- a/tools/testing/selftests/mm/seal_elf.c
> +++ b/tools/testing/selftests/mm/seal_elf.c
> @@ -105,7 +105,6 @@ static void test_seal_elf(void)
>  	int ret;
>  	FILE *maps;
>  	char line[512];
> -	int size = 0;
>  	uintptr_t  addr_start, addr_end;
>  	char prot[5];
>  	char filename[256];
> @@ -136,7 +135,7 @@ static void test_seal_elf(void)
>  	 */
>  	while (fgets(line, sizeof(line), maps)) {
>  		if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*u %255[^\n]",
> -			&addr_start, &addr_end, &prot, &filename) == 4) {
> +			&addr_start, &addr_end, (char *)&prot, (char *)&filename) == 4) {
>  			if (strlen(filename)) {
>  				/*
>  				 * seal the mapping if read only.

-- 
BR,
Muhammad Usama Anjum


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

* Re: [PATCH 1/1] selftest mm/mseal: fix compile warning
  2024-04-19  3:43 ` [PATCH 1/1] selftest mm/mseal: fix " jeffxu
  2024-04-19 16:27   ` Muhammad Usama Anjum
@ 2024-04-19 16:42   ` Pedro Falcato
  2024-04-20  0:18     ` Jeff Xu
  1 sibling, 1 reply; 5+ messages in thread
From: Pedro Falcato @ 2024-04-19 16:42 UTC (permalink / raw)
  To: jeffxu; +Cc: akpm, jeffxu, linux-kselftest, linux-mm, kernel test robot

On Fri, Apr 19, 2024 at 4:44 AM <jeffxu@chromium.org> wrote:
>
> From: Jeff Xu <jeffxu@chromium.org>
>
> fix compile warning reported by test robot
>
> Signed-off-by: Jeff Xu <jeffxu@chromium.org>
> Reported-by: kernel test robot <yujie.liu@intel.com>
> Closes: https://lore.kernel.org/r/202404190226.OfJOewV8-lkp@intel.com/
> ---
>  tools/testing/selftests/mm/mseal_test.c | 3 +--
>  tools/testing/selftests/mm/seal_elf.c   | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
> index 4a326334726d..35cdae93e580 100644
> --- a/tools/testing/selftests/mm/mseal_test.c
> +++ b/tools/testing/selftests/mm/mseal_test.c
> @@ -79,7 +79,7 @@ static unsigned long get_vma_size(void *addr, int *prot)
>                 return 0;
>
>         while (fgets(line, sizeof(line), maps)) {
> -               if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, &protstr) == 3) {
> +               if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, (char *) &protstr) == 3) {

This fix is wrong. You can simply do:

+               if (sscanf(line, "%lx-%lx %4s", &addr_start,
&addr_end, protstr) == 3) {

and it'll just work (arrays decay to pointers when required).

>                         if (addr_start == (uintptr_t) addr) {
>                                 size = addr_end - addr_start;
>                                 if (protstr[0] == 'r')
> @@ -208,7 +208,6 @@ static u64 set_pkey_bits(u64 reg, int pkey, u64 flags)
>
>  static void set_pkey(int pkey, unsigned long pkey_value)
>  {
> -       unsigned long mask = (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE);
>         u64 new_pkey_reg;
>
>         new_pkey_reg = set_pkey_bits(__read_pkey_reg(), pkey, pkey_value);
> diff --git a/tools/testing/selftests/mm/seal_elf.c b/tools/testing/selftests/mm/seal_elf.c
> index 7143dc4f1b10..b7e72f9804f8 100644
> --- a/tools/testing/selftests/mm/seal_elf.c
> +++ b/tools/testing/selftests/mm/seal_elf.c
> @@ -105,7 +105,6 @@ static void test_seal_elf(void)
>         int ret;
>         FILE *maps;
>         char line[512];
> -       int size = 0;
>         uintptr_t  addr_start, addr_end;
>         char prot[5];
>         char filename[256];
> @@ -136,7 +135,7 @@ static void test_seal_elf(void)
>          */
>         while (fgets(line, sizeof(line), maps)) {
>                 if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*u %255[^\n]",
> -                       &addr_start, &addr_end, &prot, &filename) == 4) {
> +                       &addr_start, &addr_end, (char *)&prot, (char *)&filename) == 4) {

aaand same here.

-- 
Pedro


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

* Re: [PATCH 1/1] selftest mm/mseal: fix compile warning
  2024-04-19 16:42   ` Pedro Falcato
@ 2024-04-20  0:18     ` Jeff Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Xu @ 2024-04-20  0:18 UTC (permalink / raw)
  To: Pedro Falcato; +Cc: akpm, jeffxu, linux-kselftest, linux-mm, kernel test robot

On Fri, Apr 19, 2024 at 9:43 AM Pedro Falcato <pedro.falcato@gmail.com> wrote:
>
> On Fri, Apr 19, 2024 at 4:44 AM <jeffxu@chromium.org> wrote:
> >
> > From: Jeff Xu <jeffxu@chromium.org>
> >
> > fix compile warning reported by test robot
> >
> > Signed-off-by: Jeff Xu <jeffxu@chromium.org>
> > Reported-by: kernel test robot <yujie.liu@intel.com>
> > Closes: https://lore.kernel.org/r/202404190226.OfJOewV8-lkp@intel.com/
> > ---
> >  tools/testing/selftests/mm/mseal_test.c | 3 +--
> >  tools/testing/selftests/mm/seal_elf.c   | 3 +--
> >  2 files changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c
> > index 4a326334726d..35cdae93e580 100644
> > --- a/tools/testing/selftests/mm/mseal_test.c
> > +++ b/tools/testing/selftests/mm/mseal_test.c
> > @@ -79,7 +79,7 @@ static unsigned long get_vma_size(void *addr, int *prot)
> >                 return 0;
> >
> >         while (fgets(line, sizeof(line), maps)) {
> > -               if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, &protstr) == 3) {
> > +               if (sscanf(line, "%lx-%lx %4s", &addr_start, &addr_end, (char *) &protstr) == 3) {
>
> This fix is wrong. You can simply do:
>
> +               if (sscanf(line, "%lx-%lx %4s", &addr_start,
> &addr_end, protstr) == 3) {
>
> and it'll just work (arrays decay to pointers when required).
>
Ya, that is a better fix, I will change that.
Thanks


> >                         if (addr_start == (uintptr_t) addr) {
> >                                 size = addr_end - addr_start;
> >                                 if (protstr[0] == 'r')
> > @@ -208,7 +208,6 @@ static u64 set_pkey_bits(u64 reg, int pkey, u64 flags)
> >
> >  static void set_pkey(int pkey, unsigned long pkey_value)
> >  {
> > -       unsigned long mask = (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE);
> >         u64 new_pkey_reg;
> >
> >         new_pkey_reg = set_pkey_bits(__read_pkey_reg(), pkey, pkey_value);
> > diff --git a/tools/testing/selftests/mm/seal_elf.c b/tools/testing/selftests/mm/seal_elf.c
> > index 7143dc4f1b10..b7e72f9804f8 100644
> > --- a/tools/testing/selftests/mm/seal_elf.c
> > +++ b/tools/testing/selftests/mm/seal_elf.c
> > @@ -105,7 +105,6 @@ static void test_seal_elf(void)
> >         int ret;
> >         FILE *maps;
> >         char line[512];
> > -       int size = 0;
> >         uintptr_t  addr_start, addr_end;
> >         char prot[5];
> >         char filename[256];
> > @@ -136,7 +135,7 @@ static void test_seal_elf(void)
> >          */
> >         while (fgets(line, sizeof(line), maps)) {
> >                 if (sscanf(line, "%lx-%lx %4s %*x %*x:%*x %*u %255[^\n]",
> > -                       &addr_start, &addr_end, &prot, &filename) == 4) {
> > +                       &addr_start, &addr_end, (char *)&prot, (char *)&filename) == 4) {
>
> aaand same here.
>
> --
> Pedro


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

end of thread, other threads:[~2024-04-20  0:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-19  3:43 [PATCH 0/1] selftest mm/mseal compile warning jeffxu
2024-04-19  3:43 ` [PATCH 1/1] selftest mm/mseal: fix " jeffxu
2024-04-19 16:27   ` Muhammad Usama Anjum
2024-04-19 16:42   ` Pedro Falcato
2024-04-20  0:18     ` Jeff Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).