From: Yevgeny Kliteynik <kliteyn-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: kliteyn-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
Cc: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>,
Linux RDMA <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH v2] opensm/complib/cl_passivelock.h: some casting issues
Date: Tue, 02 Feb 2010 15:20:05 +0200 [thread overview]
Message-ID: <4B682685.5040100@dev.mellanox.co.il> (raw)
In-Reply-To: <4B66FAD2.3010808-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
On 01/Feb/10 18:01, Yevgeny Kliteynik wrote:
> Sasha,
>
> There are couple of problematic castings in complib/cl_passivelock.h:
>
> (cl_status_t) pthread_rwlock_*()
>
> Turns out that compiler doesn't like casting directly from
> int to enum, probably because int can be negative:
>
> cl_passivelock.h:199: warning: cast from function call of type 'int' to non-matching type 'enum _cl_status'
> cl_passivelock.h:241: warning: cast from function call of type 'int' to non-matching type 'enum _cl_status'
> cl_passivelock.h:274: warning: cast from function call of type 'int' to non-matching type 'enum _cl_status'
> cl_passivelock.h:306: warning: cast from function call of type 'int' to non-matching type 'enum _cl_status'
>
> Se we can cast the return value in two stages - to unsigned
> and then to enum, but casting it once to unsigned solves
> the problem - the compiler can cast unsigned to enum w/o
> explicit casting.
Well, no. It can't do implicit casting in this case,
so there should be implicit casting in two stages.
V3 shortly...
-- Yevgeny
> Signed-off-by: Yevgeny Kliteynik<kliteyn-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
> ---
>
> Changes from v1: cosmetics - there was '//' at the
> end of each fixed line, removed now.
>
> opensm/include/complib/cl_passivelock.h | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/opensm/include/complib/cl_passivelock.h b/opensm/include/complib/cl_passivelock.h
> index bafd339..aba4e64 100644
> --- a/opensm/include/complib/cl_passivelock.h
> +++ b/opensm/include/complib/cl_passivelock.h
> @@ -196,7 +196,7 @@ static inline cl_status_t cl_plock_init(IN cl_plock_t * const p_lock)
> cl_status_t status;
>
> CL_ASSERT(p_lock);
> - status = (cl_status_t) pthread_rwlock_init(&p_lock->lock, NULL);
> + status = (unsigned) pthread_rwlock_init(&p_lock->lock, NULL);
> if (status)
> return CL_ERROR;
> p_lock->state = CL_INITIALIZED;
> @@ -238,7 +238,7 @@ static inline void cl_plock_acquire(IN cl_plock_t * const p_lock)
> CL_ASSERT(p_lock);
> CL_ASSERT(p_lock->state == CL_INITIALIZED);
>
> - status = (cl_status_t) pthread_rwlock_rdlock(&p_lock->lock);
> + status = (unsigned) pthread_rwlock_rdlock(&p_lock->lock);
> CL_ASSERT(status == 0);
> }
>
> @@ -271,7 +271,7 @@ static inline void cl_plock_excl_acquire(IN cl_plock_t * const p_lock)
> CL_ASSERT(p_lock);
> CL_ASSERT(p_lock->state == CL_INITIALIZED);
>
> - status = (cl_status_t) pthread_rwlock_wrlock(&p_lock->lock);
> + status = (unsigned) pthread_rwlock_wrlock(&p_lock->lock);
> CL_ASSERT(status == 0);
> }
>
> @@ -303,7 +303,7 @@ static inline void cl_plock_release(IN cl_plock_t * const p_lock)
> CL_ASSERT(p_lock);
> CL_ASSERT(p_lock->state == CL_INITIALIZED);
>
> - status = (cl_status_t) pthread_rwlock_unlock(&p_lock->lock);
> + status = (unsigned) pthread_rwlock_unlock(&p_lock->lock);
> CL_ASSERT(status == 0);
> }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2010-02-02 13:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-01 16:01 [PATCH v2] opensm/complib/cl_passivelock.h: some casting issues Yevgeny Kliteynik
[not found] ` <4B66FAD2.3010808-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2010-02-02 13:20 ` Yevgeny Kliteynik [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B682685.5040100@dev.mellanox.co.il \
--to=kliteyn-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.