]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: EINVAL on bad args to watch2
authorSage Weil <sage@redhat.com>
Sat, 8 Nov 2014 01:10:18 +0000 (17:10 -0800)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:32:38 +0000 (10:32 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/librados/librados.cc

index b86b008f35474e0213b824854111690cb1d06f8f..7f7fd10ae5315f2fd3959141ec84b5da428447a3 100644 (file)
@@ -3794,12 +3794,17 @@ extern "C" int rados_watch2(rados_ioctx_t io, const char *o, uint64_t *handle,
                            void *arg)
 {
   tracepoint(librados, rados_watch2_enter, io, o, handle, watchcb, arg);
-  uint64_t *cookie = handle;
-  librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
-  object_t oid(o);
-  C_WatchCB2 *wc = new C_WatchCB2(watchcb, watcherrcb, arg);
-  int ret = ctx->watch(oid, cookie, NULL, wc);
-  tracepoint(librados, rados_watch_exit, ret, *handle);
+  int ret;
+  if (!watchcb || !o || !handle) {
+    ret = -EINVAL;
+  } else {
+    uint64_t *cookie = handle;
+    librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
+    object_t oid(o);
+    C_WatchCB2 *wc = new C_WatchCB2(watchcb, watcherrcb, arg);
+    ret = ctx->watch(oid, cookie, NULL, wc);
+  }
+  tracepoint(librados, rados_watch_exit, ret, handle ? *handle : 0);
   return ret;
 }