Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3be790e4 authored by Aleksa Sarai's avatar Aleksa Sarai Committed by Lee Jones
Browse files

UPSTREAM: lib: test_user_copy: style cleanup



While writing the tests for copy_struct_from_user(), I used a construct
that Linus doesn't appear to be too fond of:

On 2019-10-04, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> Hmm. That code is ugly, both before and after the fix.
>
> This just doesn't make sense for so many reasons:
>
>         if ((ret |= test(umem_src == NULL, "kmalloc failed")))
>
> where the insanity comes from
>
>  - why "|=" when you know that "ret" was zero before (and it had to
>    be, for the test to make sense)
>
>  - why do this as a single line anyway?
>
>  - don't do the stupid "double parenthesis" to hide a warning. Make it
>    use an actual comparison if you add a layer of parentheses.

So instead, use a bog-standard check that isn't nearly as ugly.

Bug: 254441685
Fixes: 341115822f88 ("usercopy: Add parentheses around assignment in test_copy_struct_from_user")
Fixes: f5a1a536fa14 ("lib: introduce copy_struct_from_user() helper")
Signed-off-by: default avatarAleksa Sarai <cyphar@cyphar.com>
Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
Reviewed-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20191005233028.18566-1-cyphar@cyphar.com


Signed-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
(cherry picked from commit c90012ac85c24547e5c3468ef00aabf44aa7332d)
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: I2791bf6f4f8a1131da083203a56d601dc8598d06
parent 97ac2589
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment