linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cachefiles: Explicitly cast enumerated type in put_object
@ 2018-09-24 17:33 Nathan Chancellor
  2018-09-24 22:17 ` Nick Desaulniers
  2018-11-05 22:01 ` Nathan Chancellor
  0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2018-09-24 17:33 UTC (permalink / raw)
  To: David Howells
  Cc: linux-cachefs, linux-kernel, Nick Desaulniers, Nathan Chancellor

Clang warns when one enumerated type is implicitly converted to another.

fs/cachefiles/namei.c:247:50: warning: implicit conversion from
enumeration type 'enum cachefiles_obj_ref_trace' to different
enumeration type 'enum fscache_obj_ref_trace' [-Wenum-conversion]
        cache->cache.ops->put_object(&xobject->fscache,
cachefiles_obj_put_wait_retry);

Silence this warning by explicitly casting to fscache_obj_ref_trace,
which is also done in put_object.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 fs/cachefiles/namei.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index af2b17b21b94..15e5988a83de 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -244,11 +244,13 @@ static int cachefiles_mark_object_active(struct cachefiles_cache *cache,
 
 	ASSERT(!test_bit(CACHEFILES_OBJECT_ACTIVE, &xobject->flags));
 
-	cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_retry);
+	cache->cache.ops->put_object(&xobject->fscache,
+		(enum fscache_obj_ref_trace)cachefiles_obj_put_wait_retry);
 	goto try_again;
 
 requeue:
-	cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_timeo);
+	cache->cache.ops->put_object(&xobject->fscache,
+		(enum fscache_obj_ref_trace)cachefiles_obj_put_wait_timeo);
 	_leave(" = -ETIMEDOUT");
 	return -ETIMEDOUT;
 }
-- 
2.19.0


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

* Re: [PATCH] cachefiles: Explicitly cast enumerated type in put_object
  2018-09-24 17:33 [PATCH] cachefiles: Explicitly cast enumerated type in put_object Nathan Chancellor
@ 2018-09-24 22:17 ` Nick Desaulniers
  2018-11-05 22:01 ` Nathan Chancellor
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2018-09-24 22:17 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: dhowells, linux-cachefs, LKML

On Mon, Sep 24, 2018 at 10:33 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns when one enumerated type is implicitly converted to another.
>
> fs/cachefiles/namei.c:247:50: warning: implicit conversion from
> enumeration type 'enum cachefiles_obj_ref_trace' to different
> enumeration type 'enum fscache_obj_ref_trace' [-Wenum-conversion]
>         cache->cache.ops->put_object(&xobject->fscache,
> cachefiles_obj_put_wait_retry);

That's an interesting pattern; cachefiles_obj_ref_trace's first
enumeration's value is set to the final enumeration's value in
fscache_obj_ref_trace.  This fix is ok to me; though I would ask the
maintainer consider just merging the enums into one (unless there are
more than one other enums doing the same pattern (which doesn't seem
to be the case)).  Thanks for the patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

>
> Silence this warning by explicitly casting to fscache_obj_ref_trace,
> which is also done in put_object.
>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  fs/cachefiles/namei.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
> index af2b17b21b94..15e5988a83de 100644
> --- a/fs/cachefiles/namei.c
> +++ b/fs/cachefiles/namei.c
> @@ -244,11 +244,13 @@ static int cachefiles_mark_object_active(struct cachefiles_cache *cache,
>
>         ASSERT(!test_bit(CACHEFILES_OBJECT_ACTIVE, &xobject->flags));
>
> -       cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_retry);
> +       cache->cache.ops->put_object(&xobject->fscache,
> +               (enum fscache_obj_ref_trace)cachefiles_obj_put_wait_retry);
>         goto try_again;
>
>  requeue:
> -       cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_timeo);
> +       cache->cache.ops->put_object(&xobject->fscache,
> +               (enum fscache_obj_ref_trace)cachefiles_obj_put_wait_timeo);
>         _leave(" = -ETIMEDOUT");
>         return -ETIMEDOUT;
>  }
> --
> 2.19.0
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] cachefiles: Explicitly cast enumerated type in put_object
  2018-09-24 17:33 [PATCH] cachefiles: Explicitly cast enumerated type in put_object Nathan Chancellor
  2018-09-24 22:17 ` Nick Desaulniers
@ 2018-11-05 22:01 ` Nathan Chancellor
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2018-11-05 22:01 UTC (permalink / raw)
  To: David Howells; +Cc: linux-cachefs, linux-kernel, Nick Desaulniers

On Mon, Sep 24, 2018 at 10:33:44AM -0700, Nathan Chancellor wrote:
> Clang warns when one enumerated type is implicitly converted to another.
> 
> fs/cachefiles/namei.c:247:50: warning: implicit conversion from
> enumeration type 'enum cachefiles_obj_ref_trace' to different
> enumeration type 'enum fscache_obj_ref_trace' [-Wenum-conversion]
>         cache->cache.ops->put_object(&xobject->fscache,
> cachefiles_obj_put_wait_retry);
> 
> Silence this warning by explicitly casting to fscache_obj_ref_trace,
> which is also done in put_object.
> 
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  fs/cachefiles/namei.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
> index af2b17b21b94..15e5988a83de 100644
> --- a/fs/cachefiles/namei.c
> +++ b/fs/cachefiles/namei.c
> @@ -244,11 +244,13 @@ static int cachefiles_mark_object_active(struct cachefiles_cache *cache,
>  
>  	ASSERT(!test_bit(CACHEFILES_OBJECT_ACTIVE, &xobject->flags));
>  
> -	cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_retry);
> +	cache->cache.ops->put_object(&xobject->fscache,
> +		(enum fscache_obj_ref_trace)cachefiles_obj_put_wait_retry);
>  	goto try_again;
>  
>  requeue:
> -	cache->cache.ops->put_object(&xobject->fscache, cachefiles_obj_put_wait_timeo);
> +	cache->cache.ops->put_object(&xobject->fscache,
> +		(enum fscache_obj_ref_trace)cachefiles_obj_put_wait_timeo);
>  	_leave(" = -ETIMEDOUT");
>  	return -ETIMEDOUT;
>  }
> -- 
> 2.19.0
> 

Hi David,

Have you had a chance to take a look at this patch?

Thanks,
Nathan

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

end of thread, other threads:[~2018-11-05 22:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-24 17:33 [PATCH] cachefiles: Explicitly cast enumerated type in put_object Nathan Chancellor
2018-09-24 22:17 ` Nick Desaulniers
2018-11-05 22:01 ` Nathan Chancellor

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