]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests and tools/scratchtool: Don't attempt to use NULL xattr 6779/head
authorDan Mick <dan.mick@redhat.com>
Tue, 1 Dec 2015 22:38:48 +0000 (14:38 -0800)
committerDan Mick <dan.mick@redhat.com>
Tue, 1 Dec 2015 22:38:48 +0000 (14:38 -0800)
Prior commit changes rados{striper}_getxattrs_next to be able to return
NULL in the 'val' param.  Handle that.

Fixes: #13944
Signed-off-by: Dan Mick <dan.mick@redhat.com>
src/test/librados/c_read_operations.cc
src/test/librados/io.cc
src/test/libradosstriper/io.cc
src/tools/scratchtool.c

index d80fcdfa2eac0eff5e0cdb92e5741b8b3c52f41c..7fab5cf4e9923e5868bd455b72614eb0eab1f10a 100644 (file)
@@ -101,10 +101,11 @@ protected:
     while (i < len) {
       ASSERT_EQ(0, rados_getxattrs_next(iter, (const char**) &key,
                                        (const char**) &val, &val_len));
-      if (key == NULL || (val_len == 0 && val == NULL))
+      if (key == NULL)
        break;
       EXPECT_EQ(std::string(keys[i]), std::string(key));
-      EXPECT_EQ(0, memcmp(vals[i], val, val_len));
+      if (val != NULL)
+        EXPECT_EQ(0, memcmp(vals[i], val, val_len));
       EXPECT_EQ(lens[i], val_len);
       ++i;
     }
index cb37c45428cc93a3df78d1dc5eb5766550002409..e4af869744b0fd2dd17e7580643c48bf30142cdb 100644 (file)
@@ -559,11 +559,11 @@ TEST_F(LibRadosIo, XattrIter) {
       break;
     }
     ASSERT_LT(num_seen, 2);
-    if ((strcmp(name, attr1) == 0) && (memcmp(val, attr1_buf, len) == 0)) {
+    if ((strcmp(name, attr1) == 0) && (val != NULL) && (memcmp(val, attr1_buf, len) == 0)) {
       num_seen++;
       continue;
     }
-    else if ((strcmp(name, attr2) == 0) && (memcmp(val, attr2_buf, len) == 0)) {
+    else if ((strcmp(name, attr2) == 0) && (val != NULL) && (memcmp(val, attr2_buf, len) == 0)) {
       num_seen++;
       continue;
     }
@@ -1109,11 +1109,11 @@ TEST_F(LibRadosIoEC, XattrIter) {
       break;
     }
     ASSERT_LT(num_seen, 2);
-    if ((strcmp(name, attr1) == 0) && (memcmp(val, attr1_buf, len) == 0)) {
+    if ((strcmp(name, attr1) == 0) && (val != NULL) && (memcmp(val, attr1_buf, len) == 0)) {
       num_seen++;
       continue;
     }
-    else if ((strcmp(name, attr2) == 0) && (memcmp(val, attr2_buf, len) == 0)) {
+    else if ((strcmp(name, attr2) == 0) && (val != NULL) && (memcmp(val, attr2_buf, len) == 0)) {
       num_seen++;
       continue;
     }
index 9e56faeb0f26d6c057123711a39e30c195cdda12..2f931e5e00f6bb325b1128ec2de5b618e8d79e10 100644 (file)
@@ -357,11 +357,11 @@ TEST_F(StriperTest, XattrIter) {
       break;
     }
     ASSERT_LT(num_seen, 2) << "Extra attribute : " << name;
-    if ((strcmp(name, "attr1") == 0) && (memcmp(val, attr1_buf, len) == 0)) {
+    if ((strcmp(name, "attr1") == 0) && (val != NULL) && (memcmp(val, attr1_buf, len) == 0)) {
       num_seen++;
       continue;
     }
-    else if ((strcmp(name, "attr2") == 0) && (memcmp(val, attr2_buf, len) == 0)) {
+    else if ((strcmp(name, "attr2") == 0) && (val != NULL) && (memcmp(val, attr2_buf, len) == 0)) {
       num_seen++;
       continue;
     }
index 17d5c6b09b9a6acca7e96c0ad0e8308407f44b26..19d5e01d2d3635926bebb14b6ab1a9267a135147 100644 (file)
@@ -80,7 +80,7 @@ static int do_rados_getxattrs(rados_ioctx_t io_ctx, const char *oid,
                for (i = 0; i < nval; ++i) {
                        if (strcmp(exkeys[i], key))
                                continue;
-                       if ((len == strlen(exvals[i]) + 1) && (!strcmp(exvals[i], val))) {
+                       if ((len == strlen(exvals[i]) + 1) && (val != NULL) && (!strcmp(exvals[i], val))) {
                                nfound++;
                                break;
                        }