linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drbd: Change drbd_request_detach_interruptible's return type to int
@ 2018-09-14  5:00 Nathan Chancellor
  2018-09-14 17:34 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2018-09-14  5:00 UTC (permalink / raw)
  To: Philipp Reisner, Lars Ellenberg, Jens Axboe
  Cc: drbd-dev, linux-kernel, Nick Desaulniers, Nathan Chancellor

Clang warns when an implicit conversion is done between enumerated
types:

drivers/block/drbd/drbd_state.c:708:8: warning: implicit conversion from
enumeration type 'enum drbd_ret_code' to different enumeration type
'enum drbd_state_rv' [-Wenum-conversion]
                rv = ERR_INTR;
                   ~ ^~~~~~~~

drbd_request_detach_interruptible's only call site is in the return
statement of adm_detach, which returns an int. Change the return type of
drbd_request_detach_interruptible to match, silencing Clang's warning.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/block/drbd/drbd_state.c | 6 ++----
 drivers/block/drbd/drbd_state.h | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
index 0813c654c893..b452359b6aae 100644
--- a/drivers/block/drbd/drbd_state.c
+++ b/drivers/block/drbd/drbd_state.c
@@ -688,11 +688,9 @@ request_detach(struct drbd_device *device)
 			CS_VERBOSE | CS_ORDERED | CS_INHIBIT_MD_IO);
 }
 
-enum drbd_state_rv
-drbd_request_detach_interruptible(struct drbd_device *device)
+int drbd_request_detach_interruptible(struct drbd_device *device)
 {
-	enum drbd_state_rv rv;
-	int ret;
+	int ret, rv;
 
 	drbd_suspend_io(device); /* so no-one is stuck in drbd_al_begin_io */
 	wait_event_interruptible(device->state_wait,
diff --git a/drivers/block/drbd/drbd_state.h b/drivers/block/drbd/drbd_state.h
index ea58301d0895..cff0a34c150b 100644
--- a/drivers/block/drbd/drbd_state.h
+++ b/drivers/block/drbd/drbd_state.h
@@ -162,8 +162,7 @@ static inline int drbd_request_state(struct drbd_device *device,
 }
 
 /* for use in adm_detach() (drbd_adm_detach(), drbd_adm_down()) */
-enum drbd_state_rv
-drbd_request_detach_interruptible(struct drbd_device *device);
+int drbd_request_detach_interruptible(struct drbd_device *device);
 
 enum drbd_role conn_highest_role(struct drbd_connection *connection);
 enum drbd_role conn_highest_peer(struct drbd_connection *connection);
-- 
2.18.0


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

* Re: [PATCH] drbd: Change drbd_request_detach_interruptible's return type to int
  2018-09-14  5:00 [PATCH] drbd: Change drbd_request_detach_interruptible's return type to int Nathan Chancellor
@ 2018-09-14 17:34 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2018-09-14 17:34 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: philipp.reisner, lars.ellenberg, axboe, drbd-dev, LKML

On Thu, Sep 13, 2018 at 10:01 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns when an implicit conversion is done between enumerated
> types:
>
> drivers/block/drbd/drbd_state.c:708:8: warning: implicit conversion from
> enumeration type 'enum drbd_ret_code' to different enumeration type
> 'enum drbd_state_rv' [-Wenum-conversion]
>                 rv = ERR_INTR;
>                    ~ ^~~~~~~~
>
> drbd_request_detach_interruptible's only call site is in the return
> statement of adm_detach, which returns an int. Change the return type of
> drbd_request_detach_interruptible to match, silencing Clang's warning.

Yeah with one call site that passes along the return value, that's the
right fix to IMO.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/block/drbd/drbd_state.c | 6 ++----
>  drivers/block/drbd/drbd_state.h | 3 +--
>  2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
> index 0813c654c893..b452359b6aae 100644
> --- a/drivers/block/drbd/drbd_state.c
> +++ b/drivers/block/drbd/drbd_state.c
> @@ -688,11 +688,9 @@ request_detach(struct drbd_device *device)
>                         CS_VERBOSE | CS_ORDERED | CS_INHIBIT_MD_IO);
>  }
>
> -enum drbd_state_rv
> -drbd_request_detach_interruptible(struct drbd_device *device)
> +int drbd_request_detach_interruptible(struct drbd_device *device)
>  {
> -       enum drbd_state_rv rv;
> -       int ret;
> +       int ret, rv;
>
>         drbd_suspend_io(device); /* so no-one is stuck in drbd_al_begin_io */
>         wait_event_interruptible(device->state_wait,
> diff --git a/drivers/block/drbd/drbd_state.h b/drivers/block/drbd/drbd_state.h
> index ea58301d0895..cff0a34c150b 100644
> --- a/drivers/block/drbd/drbd_state.h
> +++ b/drivers/block/drbd/drbd_state.h
> @@ -162,8 +162,7 @@ static inline int drbd_request_state(struct drbd_device *device,
>  }
>
>  /* for use in adm_detach() (drbd_adm_detach(), drbd_adm_down()) */
> -enum drbd_state_rv
> -drbd_request_detach_interruptible(struct drbd_device *device);
> +int drbd_request_detach_interruptible(struct drbd_device *device);
>
>  enum drbd_role conn_highest_role(struct drbd_connection *connection);
>  enum drbd_role conn_highest_peer(struct drbd_connection *connection);
> --
> 2.18.0
>


-- 
Thanks,
~Nick Desaulniers

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

end of thread, other threads:[~2018-09-14 17:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14  5:00 [PATCH] drbd: Change drbd_request_detach_interruptible's return type to int Nathan Chancellor
2018-09-14 17:34 ` Nick Desaulniers

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).