diff mbox

[1/2] utime: fix narrowing conversion compiler warning in sleep()

Message ID 1359320252-2445-2-git-send-email-danny.al-gaaf@bisect.de (mailing list archive)
State New, archived
Headers show

Commit Message

Danny Al-Gaaf Jan. 27, 2013, 8:57 p.m. UTC
Fix compiler warning:
./include/utime.h: In member function 'void utime_t::sleep()':
./include/utime.h:139:50: warning: narrowing conversion of
 '((utime_t*)this)->utime_t::tv.utime_t::<anonymous struct>::tv_sec' from
 '__u32 {aka unsigned int}' to '__time_t {aka long int}' inside { } is
 ill-formed in C++11 [-Wnarrowing]
./include/utime.h:139:50: warning: narrowing conversion of
 '((utime_t*)this)->utime_t::tv.utime_t::<anonymous struct>::tv_nsec' from
 '__u32 {aka unsigned int}' to 'long int' inside { } is
 ill-formed in C++11 [-Wnarrowing]

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
---
 src/include/utime.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Danny Al-Gaaf Jan. 29, 2013, 11:52 a.m. UTC | #1
Hi,

could someone cherry-pick this patch to the bobtail branch? I see the
same issue there.

Thanks!

Danny


Am 27.01.2013 21:57, schrieb Danny Al-Gaaf:
> Fix compiler warning:
> ./include/utime.h: In member function 'void utime_t::sleep()':
> ./include/utime.h:139:50: warning: narrowing conversion of
>  '((utime_t*)this)->utime_t::tv.utime_t::<anonymous struct>::tv_sec' from
>  '__u32 {aka unsigned int}' to '__time_t {aka long int}' inside { } is
>  ill-formed in C++11 [-Wnarrowing]
> ./include/utime.h:139:50: warning: narrowing conversion of
>  '((utime_t*)this)->utime_t::tv.utime_t::<anonymous struct>::tv_nsec' from
>  '__u32 {aka unsigned int}' to 'long int' inside { } is
>  ill-formed in C++11 [-Wnarrowing]
> 
> Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
> ---
>  src/include/utime.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/include/utime.h b/src/include/utime.h
> index 526dec5..f433fff 100644
> --- a/src/include/utime.h
> +++ b/src/include/utime.h
> @@ -136,7 +136,7 @@ public:
>    }
>  
>    void sleep() {
> -    struct timespec ts = { tv.tv_sec, tv.tv_nsec };
> +    struct timespec ts = { (__time_t)tv.tv_sec, (long)tv.tv_nsec };
>      nanosleep(&ts, &ts);
>    }
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sage Weil Jan. 29, 2013, 8:34 p.m. UTC | #2
On Tue, 29 Jan 2013, Danny Al-Gaaf wrote:
> Hi,
> 
> could someone cherry-pick this patch to the bobtail branch? I see the
> same issue there.

Cherry-picked, thanks!

s

> 
> Thanks!
> 
> Danny
> 
> 
> Am 27.01.2013 21:57, schrieb Danny Al-Gaaf:
> > Fix compiler warning:
> > ./include/utime.h: In member function 'void utime_t::sleep()':
> > ./include/utime.h:139:50: warning: narrowing conversion of
> >  '((utime_t*)this)->utime_t::tv.utime_t::<anonymous struct>::tv_sec' from
> >  '__u32 {aka unsigned int}' to '__time_t {aka long int}' inside { } is
> >  ill-formed in C++11 [-Wnarrowing]
> > ./include/utime.h:139:50: warning: narrowing conversion of
> >  '((utime_t*)this)->utime_t::tv.utime_t::<anonymous struct>::tv_nsec' from
> >  '__u32 {aka unsigned int}' to 'long int' inside { } is
> >  ill-formed in C++11 [-Wnarrowing]
> > 
> > Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
> > ---
> >  src/include/utime.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/include/utime.h b/src/include/utime.h
> > index 526dec5..f433fff 100644
> > --- a/src/include/utime.h
> > +++ b/src/include/utime.h
> > @@ -136,7 +136,7 @@ public:
> >    }
> >  
> >    void sleep() {
> > -    struct timespec ts = { tv.tv_sec, tv.tv_nsec };
> > +    struct timespec ts = { (__time_t)tv.tv_sec, (long)tv.tv_nsec };
> >      nanosleep(&ts, &ts);
> >    }
> >  
> > 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/include/utime.h b/src/include/utime.h
index 526dec5..f433fff 100644
--- a/src/include/utime.h
+++ b/src/include/utime.h
@@ -136,7 +136,7 @@  public:
   }
 
   void sleep() {
-    struct timespec ts = { tv.tv_sec, tv.tv_nsec };
+    struct timespec ts = { (__time_t)tv.tv_sec, (long)tv.tv_nsec };
     nanosleep(&ts, &ts);
   }