Re: [PATCH v2] memfd_test: Make it work on 32-bit systems

2014-09-03 Thread Pranith Kumar
On Wed, Sep 3, 2014 at 1:53 AM, David Herrmann  wrote:

> Sorry for the bike-shedding. Patch looks good, otherwise. With, or
> without, this changed, this is:
>
> Reviewed-by: David Herrmann 
>

Thank you for the review David. I will send in a new patch with your
suggested changes.

-- 
Pranith
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] memfd_test: Make it work on 32-bit systems

2014-09-03 Thread Pranith Kumar
On Wed, Sep 3, 2014 at 1:53 AM, David Herrmann dh.herrm...@gmail.com wrote:

 Sorry for the bike-shedding. Patch looks good, otherwise. With, or
 without, this changed, this is:

 Reviewed-by: David Herrmann dh.herrm...@gmail.com


Thank you for the review David. I will send in a new patch with your
suggested changes.

-- 
Pranith
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] memfd_test: Make it work on 32-bit systems

2014-09-02 Thread David Herrmann
Hi

On Mon, Sep 1, 2014 at 7:08 PM, Pranith Kumar  wrote:
> This test currently fails on 32-bit systems since we use u64 type to pass the
> flags to fcntl.
>
> This commit changes this to use 'unsigned int' type for flags to fcntl making 
> it
> work on 32-bit systems.
>
> Signed-off-by: Pranith Kumar 
> ---
> v2: use 'unsigned int' instead of u32
>
>  tools/testing/selftests/memfd/memfd_test.c | 30 
> ++
>  1 file changed, 14 insertions(+), 16 deletions(-)
>
> diff --git a/tools/testing/selftests/memfd/memfd_test.c 
> b/tools/testing/selftests/memfd/memfd_test.c
> index 3634c90..6f1385a 100644
> --- a/tools/testing/selftests/memfd/memfd_test.c
> +++ b/tools/testing/selftests/memfd/memfd_test.c
> @@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int 
> flags)
> }
>  }
>
> -static __u64 mfd_assert_get_seals(int fd)
> +static int mfd_assert_get_seals(int fd)
>  {
> -   long r;
> +   int r;

This function can be declared as returning "unsigned int", but keep
"r" as int. negative return codes cause an abort(), so we're fine.

>
> r = fcntl(fd, F_GET_SEALS);
> if (r < 0) {
> @@ -72,36 +72,34 @@ static __u64 mfd_assert_get_seals(int fd)
> return r;
>  }
>
> -static void mfd_assert_has_seals(int fd, __u64 seals)
> +static void mfd_assert_has_seals(int fd, unsigned int seals)
>  {
> -   __u64 s;
> +   int s;
>
> s = mfd_assert_get_seals(fd);
> if (s != seals) {
> -   printf("%llu != %llu = GET_SEALS(%d)\n",
> -  (unsigned long long)seals, (unsigned long long)s, fd);
> +   printf("%u != %u = GET_SEALS(%d)\n",
> +   seals, (unsigned int)s, fd);

By making mfd_assert_get_seals() return "unsigned int", you can
declare 's' as unsigned, too, and drop this cast.

> abort();
> }
>  }
>
> -static void mfd_assert_add_seals(int fd, __u64 seals)
> +static void mfd_assert_add_seals(int fd, unsigned int seals)
>  {
> -   long r;
> -   __u64 s;
> +   int r, s;
>
> s = mfd_assert_get_seals(fd);
> r = fcntl(fd, F_ADD_SEALS, seals);
> if (r < 0) {
> -   printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n",
> -  fd, (unsigned long long)s, (unsigned long long)seals);
> +   printf("ADD_SEALS(%d, %u -> %u) failed: %m\n",
> +   fd, (unsigned int)s, seals);

same here

> abort();
> }
>  }
>
> -static void mfd_fail_add_seals(int fd, __u64 seals)
> +static void mfd_fail_add_seals(int fd, unsigned int seals)
>  {
> -   long r;
> -   __u64 s;
> +   int r, s;
>
> r = fcntl(fd, F_GET_SEALS);
> if (r < 0)
> @@ -111,8 +109,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals)
>
> r = fcntl(fd, F_ADD_SEALS, seals);
> if (r >= 0) {
> -   printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as 
> expected\n",
> -  fd, (unsigned long long)s, (unsigned long long)seals);
> +   printf("ADD_SEALS(%d, %u -> %u) didn't fail as expected\n",
> +   fd, (unsigned int)s, seals);

same here

Sorry for the bike-shedding. Patch looks good, otherwise. With, or
without, this changed, this is:

Reviewed-by: David Herrmann 

Thanks
David

> abort();
> }
>  }
> --
> 2.1.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] memfd_test: Make it work on 32-bit systems

2014-09-02 Thread David Herrmann
Hi

On Mon, Sep 1, 2014 at 7:08 PM, Pranith Kumar bobby.pr...@gmail.com wrote:
 This test currently fails on 32-bit systems since we use u64 type to pass the
 flags to fcntl.

 This commit changes this to use 'unsigned int' type for flags to fcntl making 
 it
 work on 32-bit systems.

 Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
 ---
 v2: use 'unsigned int' instead of u32

  tools/testing/selftests/memfd/memfd_test.c | 30 
 ++
  1 file changed, 14 insertions(+), 16 deletions(-)

 diff --git a/tools/testing/selftests/memfd/memfd_test.c 
 b/tools/testing/selftests/memfd/memfd_test.c
 index 3634c90..6f1385a 100644
 --- a/tools/testing/selftests/memfd/memfd_test.c
 +++ b/tools/testing/selftests/memfd/memfd_test.c
 @@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int 
 flags)
 }
  }

 -static __u64 mfd_assert_get_seals(int fd)
 +static int mfd_assert_get_seals(int fd)
  {
 -   long r;
 +   int r;

This function can be declared as returning unsigned int, but keep
r as int. negative return codes cause an abort(), so we're fine.


 r = fcntl(fd, F_GET_SEALS);
 if (r  0) {
 @@ -72,36 +72,34 @@ static __u64 mfd_assert_get_seals(int fd)
 return r;
  }

 -static void mfd_assert_has_seals(int fd, __u64 seals)
 +static void mfd_assert_has_seals(int fd, unsigned int seals)
  {
 -   __u64 s;
 +   int s;

 s = mfd_assert_get_seals(fd);
 if (s != seals) {
 -   printf(%llu != %llu = GET_SEALS(%d)\n,
 -  (unsigned long long)seals, (unsigned long long)s, fd);
 +   printf(%u != %u = GET_SEALS(%d)\n,
 +   seals, (unsigned int)s, fd);

By making mfd_assert_get_seals() return unsigned int, you can
declare 's' as unsigned, too, and drop this cast.

 abort();
 }
  }

 -static void mfd_assert_add_seals(int fd, __u64 seals)
 +static void mfd_assert_add_seals(int fd, unsigned int seals)
  {
 -   long r;
 -   __u64 s;
 +   int r, s;

 s = mfd_assert_get_seals(fd);
 r = fcntl(fd, F_ADD_SEALS, seals);
 if (r  0) {
 -   printf(ADD_SEALS(%d, %llu - %llu) failed: %m\n,
 -  fd, (unsigned long long)s, (unsigned long long)seals);
 +   printf(ADD_SEALS(%d, %u - %u) failed: %m\n,
 +   fd, (unsigned int)s, seals);

same here

 abort();
 }
  }

 -static void mfd_fail_add_seals(int fd, __u64 seals)
 +static void mfd_fail_add_seals(int fd, unsigned int seals)
  {
 -   long r;
 -   __u64 s;
 +   int r, s;

 r = fcntl(fd, F_GET_SEALS);
 if (r  0)
 @@ -111,8 +109,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals)

 r = fcntl(fd, F_ADD_SEALS, seals);
 if (r = 0) {
 -   printf(ADD_SEALS(%d, %llu - %llu) didn't fail as 
 expected\n,
 -  fd, (unsigned long long)s, (unsigned long long)seals);
 +   printf(ADD_SEALS(%d, %u - %u) didn't fail as expected\n,
 +   fd, (unsigned int)s, seals);

same here

Sorry for the bike-shedding. Patch looks good, otherwise. With, or
without, this changed, this is:

Reviewed-by: David Herrmann dh.herrm...@gmail.com

Thanks
David

 abort();
 }
  }
 --
 2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] memfd_test: Make it work on 32-bit systems

2014-09-01 Thread Pranith Kumar
This test currently fails on 32-bit systems since we use u64 type to pass the
flags to fcntl.

This commit changes this to use 'unsigned int' type for flags to fcntl making it
work on 32-bit systems.

Signed-off-by: Pranith Kumar 
---
v2: use 'unsigned int' instead of u32

 tools/testing/selftests/memfd/memfd_test.c | 30 ++
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c 
b/tools/testing/selftests/memfd/memfd_test.c
index 3634c90..6f1385a 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags)
}
 }
 
-static __u64 mfd_assert_get_seals(int fd)
+static int mfd_assert_get_seals(int fd)
 {
-   long r;
+   int r;
 
r = fcntl(fd, F_GET_SEALS);
if (r < 0) {
@@ -72,36 +72,34 @@ static __u64 mfd_assert_get_seals(int fd)
return r;
 }
 
-static void mfd_assert_has_seals(int fd, __u64 seals)
+static void mfd_assert_has_seals(int fd, unsigned int seals)
 {
-   __u64 s;
+   int s;
 
s = mfd_assert_get_seals(fd);
if (s != seals) {
-   printf("%llu != %llu = GET_SEALS(%d)\n",
-  (unsigned long long)seals, (unsigned long long)s, fd);
+   printf("%u != %u = GET_SEALS(%d)\n",
+   seals, (unsigned int)s, fd);
abort();
}
 }
 
-static void mfd_assert_add_seals(int fd, __u64 seals)
+static void mfd_assert_add_seals(int fd, unsigned int seals)
 {
-   long r;
-   __u64 s;
+   int r, s;
 
s = mfd_assert_get_seals(fd);
r = fcntl(fd, F_ADD_SEALS, seals);
if (r < 0) {
-   printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n",
-  fd, (unsigned long long)s, (unsigned long long)seals);
+   printf("ADD_SEALS(%d, %u -> %u) failed: %m\n",
+   fd, (unsigned int)s, seals);
abort();
}
 }
 
-static void mfd_fail_add_seals(int fd, __u64 seals)
+static void mfd_fail_add_seals(int fd, unsigned int seals)
 {
-   long r;
-   __u64 s;
+   int r, s;
 
r = fcntl(fd, F_GET_SEALS);
if (r < 0)
@@ -111,8 +109,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals)
 
r = fcntl(fd, F_ADD_SEALS, seals);
if (r >= 0) {
-   printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected\n",
-  fd, (unsigned long long)s, (unsigned long long)seals);
+   printf("ADD_SEALS(%d, %u -> %u) didn't fail as expected\n",
+   fd, (unsigned int)s, seals);
abort();
}
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] memfd_test: Make it work on 32-bit systems

2014-09-01 Thread Pranith Kumar
This test currently fails on 32-bit systems since we use u64 type to pass the
flags to fcntl.

This commit changes this to use 'unsigned int' type for flags to fcntl making it
work on 32-bit systems.

Signed-off-by: Pranith Kumar bobby.pr...@gmail.com
---
v2: use 'unsigned int' instead of u32

 tools/testing/selftests/memfd/memfd_test.c | 30 ++
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c 
b/tools/testing/selftests/memfd/memfd_test.c
index 3634c90..6f1385a 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags)
}
 }
 
-static __u64 mfd_assert_get_seals(int fd)
+static int mfd_assert_get_seals(int fd)
 {
-   long r;
+   int r;
 
r = fcntl(fd, F_GET_SEALS);
if (r  0) {
@@ -72,36 +72,34 @@ static __u64 mfd_assert_get_seals(int fd)
return r;
 }
 
-static void mfd_assert_has_seals(int fd, __u64 seals)
+static void mfd_assert_has_seals(int fd, unsigned int seals)
 {
-   __u64 s;
+   int s;
 
s = mfd_assert_get_seals(fd);
if (s != seals) {
-   printf(%llu != %llu = GET_SEALS(%d)\n,
-  (unsigned long long)seals, (unsigned long long)s, fd);
+   printf(%u != %u = GET_SEALS(%d)\n,
+   seals, (unsigned int)s, fd);
abort();
}
 }
 
-static void mfd_assert_add_seals(int fd, __u64 seals)
+static void mfd_assert_add_seals(int fd, unsigned int seals)
 {
-   long r;
-   __u64 s;
+   int r, s;
 
s = mfd_assert_get_seals(fd);
r = fcntl(fd, F_ADD_SEALS, seals);
if (r  0) {
-   printf(ADD_SEALS(%d, %llu - %llu) failed: %m\n,
-  fd, (unsigned long long)s, (unsigned long long)seals);
+   printf(ADD_SEALS(%d, %u - %u) failed: %m\n,
+   fd, (unsigned int)s, seals);
abort();
}
 }
 
-static void mfd_fail_add_seals(int fd, __u64 seals)
+static void mfd_fail_add_seals(int fd, unsigned int seals)
 {
-   long r;
-   __u64 s;
+   int r, s;
 
r = fcntl(fd, F_GET_SEALS);
if (r  0)
@@ -111,8 +109,8 @@ static void mfd_fail_add_seals(int fd, __u64 seals)
 
r = fcntl(fd, F_ADD_SEALS, seals);
if (r = 0) {
-   printf(ADD_SEALS(%d, %llu - %llu) didn't fail as expected\n,
-  fd, (unsigned long long)s, (unsigned long long)seals);
+   printf(ADD_SEALS(%d, %u - %u) didn't fail as expected\n,
+   fd, (unsigned int)s, seals);
abort();
}
 }
-- 
2.1.0

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/