diff mbox series

[v1] xen/xenbus: Convert to use ERR_CAST()

Message ID 20240829084710.30312-1-shenlichuan@vivo.com (mailing list archive)
State Accepted
Commit 66618315515fb64da24fa72c9c636dbf4baad8f8
Headers show
Series [v1] xen/xenbus: Convert to use ERR_CAST() | expand

Commit Message

Shen Lichuan Aug. 29, 2024, 8:47 a.m. UTC
Use ERR_CAST() as it is designed for casting an error pointer to 
another type.

This macro utilizes the __force and __must_check modifiers, which instruct 
the compiler to verify for errors at the locations where it is employed.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
 drivers/xen/xenbus/xenbus_xs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Jürgen Groß Sept. 10, 2024, 1:49 p.m. UTC | #1
On 29.08.24 10:47, Shen Lichuan wrote:
> Use ERR_CAST() as it is designed for casting an error pointer to
> another type.
> 
> This macro utilizes the __force and __must_check modifiers, which instruct
> the compiler to verify for errors at the locations where it is employed.
> 
> Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
diff mbox series

Patch

diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 028a182bcc9e..d32c726f7a12 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -427,12 +427,12 @@  char **xenbus_directory(struct xenbus_transaction t,
 
 	path = join(dir, node);
 	if (IS_ERR(path))
-		return (char **)path;
+		return ERR_CAST(path);
 
 	strings = xs_single(t, XS_DIRECTORY, path, &len);
 	kfree(path);
 	if (IS_ERR(strings))
-		return (char **)strings;
+		return ERR_CAST(strings);
 
 	return split(strings, len, num);
 }
@@ -465,7 +465,7 @@  void *xenbus_read(struct xenbus_transaction t,
 
 	path = join(dir, node);
 	if (IS_ERR(path))
-		return (void *)path;
+		return ERR_CAST(path);
 
 	ret = xs_single(t, XS_READ, path, len);
 	kfree(path);