All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fix some compiler warnings
@ 2013-01-27 20:57 Danny Al-Gaaf
  2013-01-27 20:57 ` [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep() Danny Al-Gaaf
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Danny Al-Gaaf @ 2013-01-27 20:57 UTC (permalink / raw)
  To: ceph-devel; +Cc: Danny Al-Gaaf, Sage Weil

Attached two patches to fix some compiler warnings.

Danny Al-Gaaf (2):
  utime: fix narrowing conversion compiler warning in sleep()
  rbd: don't ignore return value of system()

 src/include/utime.h |  2 +-
 src/rbd.cc          | 36 ++++++++++++++++++++++++++++++------
 2 files changed, 31 insertions(+), 7 deletions(-)

-- 
1.8.1.1


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

* [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep()
  2013-01-27 20:57 [PATCH 0/2] fix some compiler warnings Danny Al-Gaaf
@ 2013-01-27 20:57 ` Danny Al-Gaaf
  2013-01-29 11:52   ` Danny Al-Gaaf
  2013-01-27 20:57 ` [PATCH 2/2] rbd: don't ignore return value of system() Danny Al-Gaaf
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Danny Al-Gaaf @ 2013-01-27 20:57 UTC (permalink / raw)
  To: ceph-devel; +Cc: Danny Al-Gaaf, Sage Weil

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);
   }
 
-- 
1.8.1.1


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

* [PATCH 2/2] rbd: don't ignore return value of system()
  2013-01-27 20:57 [PATCH 0/2] fix some compiler warnings Danny Al-Gaaf
  2013-01-27 20:57 ` [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep() Danny Al-Gaaf
@ 2013-01-27 20:57 ` Danny Al-Gaaf
  2013-01-28 18:47 ` [PATCH 0/2] fix some compiler warnings Dan Mick
  2013-01-28 23:23 ` Dan Mick
  3 siblings, 0 replies; 7+ messages in thread
From: Danny Al-Gaaf @ 2013-01-27 20:57 UTC (permalink / raw)
  To: ceph-devel; +Cc: Danny Al-Gaaf, Sage Weil

Check for the return value of system() and handle the error if needed

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
---
 src/rbd.cc | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/rbd.cc b/src/rbd.cc
index 833188a..bdbc684 100644
--- a/src/rbd.cc
+++ b/src/rbd.cc
@@ -1428,8 +1428,16 @@ static int do_kernel_add(const char *poolname, const char *imgname,
 
   // modprobe the rbd module if /sys/bus/rbd doesn't exist
   struct stat sb;
-  if ((stat("/sys/bus/rbd", &sb) < 0) || (!S_ISDIR(sb.st_mode)))
-    system("/sbin/modprobe rbd");
+  if ((stat("/sys/bus/rbd", &sb) < 0) || (!S_ISDIR(sb.st_mode))) {
+    r = system("/sbin/modprobe rbd");
+    if (r) {
+      if (r < 0)  
+        cerr << "rbd: error executing modprobe as shell command!" << std::endl;
+      else
+        cerr << "rbd: modprobe rbd failed! (" << r << ")" <<std::endl;
+      return r;
+    }
+  }
 
   // write to /sys/bus/rbd/add
   int fd = open("/sys/bus/rbd/add", O_WRONLY);
@@ -1448,8 +1456,16 @@ static int do_kernel_add(const char *poolname, const char *imgname,
   close(fd);
 
   // let udevadm do its job before we return
-  if (udevadm_settle)
-    system("/sbin/udevadm settle");
+  if (udevadm_settle) {
+    r = system("/sbin/udevadm settle");
+    if (r) {
+      if (r < 0)  
+        cerr << "rbd: error executing udevadm as shell command!" << std::endl;
+      else
+        cerr << "rbd: '/sbin/udevadm settle' failed! (" << r << ")" <<std::endl;
+      return r;
+    }
+  }
 
   return r;
 }
@@ -1664,8 +1680,16 @@ static int do_kernel_rm(const char *dev)
   r = close(fd);
 
   // let udevadm finish, if present
-  if (udevadm_settle)
-    system("/sbin/udevadm settle");
+  if (udevadm_settle){
+    r = system("/sbin/udevadm settle");
+    if (r) {
+      if (r < 0)  
+        cerr << "rbd: error executing udevadm as shell command!" << std::endl;
+      else
+        cerr << "rbd: '/sbin/udevadm settle' failed! (" << r << ")" <<std::endl;
+      return r;
+    }
+  }
 
   if (r < 0)
     r = -errno;
-- 
1.8.1.1


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

* Re: [PATCH 0/2] fix some compiler warnings
  2013-01-27 20:57 [PATCH 0/2] fix some compiler warnings Danny Al-Gaaf
  2013-01-27 20:57 ` [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep() Danny Al-Gaaf
  2013-01-27 20:57 ` [PATCH 2/2] rbd: don't ignore return value of system() Danny Al-Gaaf
@ 2013-01-28 18:47 ` Dan Mick
  2013-01-28 23:23 ` Dan Mick
  3 siblings, 0 replies; 7+ messages in thread
From: Dan Mick @ 2013-01-28 18:47 UTC (permalink / raw)
  To: Danny Al-Gaaf; +Cc: ceph-devel, Danny Al-Gaaf, Sage Weil

I'd just noticed utime on my laptop 32-bit build and was trying to figure out why our 32-bit nightly didn't see it. And Greg had seen the system build problem where I didn't, and I was isolating differences there as well. 

I purposely didn't spend time on the system() error handling because I was thinking of those calls as best-effort, if they fail the map will likely fail anyway, but there's no harm in handling errors, particularly if it'll shit the compiler up :)

On Jan 27, 2013, at 12:57 PM, Danny Al-Gaaf <danny.al-gaaf@bisect.de> wrote:

> Attached two patches to fix some compiler warnings.
> 
> Danny Al-Gaaf (2):
>  utime: fix narrowing conversion compiler warning in sleep()
>  rbd: don't ignore return value of system()
> 
> src/include/utime.h |  2 +-
> src/rbd.cc          | 36 ++++++++++++++++++++++++++++++------
> 2 files changed, 31 insertions(+), 7 deletions(-)
> 
> -- 
> 1.8.1.1
> 
> --
> 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

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

* Re: [PATCH 0/2] fix some compiler warnings
  2013-01-27 20:57 [PATCH 0/2] fix some compiler warnings Danny Al-Gaaf
                   ` (2 preceding siblings ...)
  2013-01-28 18:47 ` [PATCH 0/2] fix some compiler warnings Dan Mick
@ 2013-01-28 23:23 ` Dan Mick
  3 siblings, 0 replies; 7+ messages in thread
From: Dan Mick @ 2013-01-28 23:23 UTC (permalink / raw)
  To: Danny Al-Gaaf; +Cc: ceph-devel

Sage merged these into master.  Thanks!

On 01/27/2013 12:57 PM, Danny Al-Gaaf wrote:
> Attached two patches to fix some compiler warnings.
>
> Danny Al-Gaaf (2):
>    utime: fix narrowing conversion compiler warning in sleep()
>    rbd: don't ignore return value of system()
>
>   src/include/utime.h |  2 +-
>   src/rbd.cc          | 36 ++++++++++++++++++++++++++++++------
>   2 files changed, 31 insertions(+), 7 deletions(-)
>

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

* Re: [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep()
  2013-01-27 20:57 ` [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep() Danny Al-Gaaf
@ 2013-01-29 11:52   ` Danny Al-Gaaf
  2013-01-29 20:34     ` Sage Weil
  0 siblings, 1 reply; 7+ messages in thread
From: Danny Al-Gaaf @ 2013-01-29 11:52 UTC (permalink / raw)
  To: ceph-devel; +Cc: Sage Weil

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);
>    }
>  
> 


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

* Re: [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep()
  2013-01-29 11:52   ` Danny Al-Gaaf
@ 2013-01-29 20:34     ` Sage Weil
  0 siblings, 0 replies; 7+ messages in thread
From: Sage Weil @ 2013-01-29 20:34 UTC (permalink / raw)
  To: Danny Al-Gaaf; +Cc: ceph-devel

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);
> >    }
> >  
> > 
> 
> 

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

end of thread, other threads:[~2013-01-29 20:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-27 20:57 [PATCH 0/2] fix some compiler warnings Danny Al-Gaaf
2013-01-27 20:57 ` [PATCH 1/2] utime: fix narrowing conversion compiler warning in sleep() Danny Al-Gaaf
2013-01-29 11:52   ` Danny Al-Gaaf
2013-01-29 20:34     ` Sage Weil
2013-01-27 20:57 ` [PATCH 2/2] rbd: don't ignore return value of system() Danny Al-Gaaf
2013-01-28 18:47 ` [PATCH 0/2] fix some compiler warnings Dan Mick
2013-01-28 23:23 ` Dan Mick

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.