diff mbox series

[-next] apparmor: Use IS_ERR_OR_NULL() helper function

Message ID 20240828122618.3697392-1-lihongbo22@huawei.com (mailing list archive)
State Handled Elsewhere
Delegated to: Paul Moore
Headers show
Series [-next] apparmor: Use IS_ERR_OR_NULL() helper function | expand

Commit Message

Hongbo Li Aug. 28, 2024, 12:26 p.m. UTC
Use the IS_ERR_OR_NULL() helper instead of open-coding a
NULL and an error pointer checks to simplify the code and
improve readability.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 security/apparmor/path.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Johansen Sept. 10, 2024, 6:22 a.m. UTC | #1
On 8/28/24 05:26, Hongbo Li wrote:
> Use the IS_ERR_OR_NULL() helper instead of open-coding a
> NULL and an error pointer checks to simplify the code and
> improve readability.
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>

Acked-by: John Johansen <john.johansen@canonical.com>

I have pulled this into my tree

> ---
>   security/apparmor/path.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/security/apparmor/path.c b/security/apparmor/path.c
> index 45ec994b558d..d6c74c357ffd 100644
> --- a/security/apparmor/path.c
> +++ b/security/apparmor/path.c
> @@ -130,7 +130,7 @@ static int d_namespace_path(const struct path *path, char *buf, char **name,
>   	/* handle error conditions - and still allow a partial path to
>   	 * be returned.
>   	 */
> -	if (!res || IS_ERR(res)) {
> +	if (IS_ERR_OR_NULL(res)) {
>   		if (PTR_ERR(res) == -ENAMETOOLONG) {
>   			error = -ENAMETOOLONG;
>   			*name = buf;
diff mbox series

Patch

diff --git a/security/apparmor/path.c b/security/apparmor/path.c
index 45ec994b558d..d6c74c357ffd 100644
--- a/security/apparmor/path.c
+++ b/security/apparmor/path.c
@@ -130,7 +130,7 @@  static int d_namespace_path(const struct path *path, char *buf, char **name,
 	/* handle error conditions - and still allow a partial path to
 	 * be returned.
 	 */
-	if (!res || IS_ERR(res)) {
+	if (IS_ERR_OR_NULL(res)) {
 		if (PTR_ERR(res) == -ENAMETOOLONG) {
 			error = -ENAMETOOLONG;
 			*name = buf;