lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [13/15] git commit: refs/heads/cfish-string-prep1 - Make sure the return value of INCREF is used
Date Sat, 14 Sep 2013 19:29:45 GMT
Make sure the return value of INCREF is used

Verified by temporarily adding __attribute__((warn_unused_result)) to
CFISH_Obj_Inc_RefCount.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/6f3f7525
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/6f3f7525
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/6f3f7525

Branch: refs/heads/cfish-string-prep1
Commit: 6f3f7525399d6958d526a5759906be1039c810c7
Parents: 6f48dc3
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Fri May 10 19:06:00 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sat Sep 14 20:50:22 2013 +0200

----------------------------------------------------------------------
 c/src/Lucy/Document/Doc.c                                     | 6 ++----
 clownfish/runtime/core/Clownfish/Test/TestObj.c               | 2 +-
 clownfish/runtime/core/Clownfish/Test/TestVArray.c            | 2 +-
 .../runtime/core/Clownfish/TestHarness/TestBatchRunner.c      | 3 +--
 core/Lucy/Index/LexIndex.c                                    | 2 +-
 core/Lucy/Index/Snapshot.c                                    | 5 ++---
 core/Lucy/Index/SortReader.c                                  | 7 +++----
 core/Lucy/Index/ZombieKeyedHash.c                             | 2 +-
 core/Lucy/Search/QueryParser/ParserElem.c                     | 4 ++--
 9 files changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/c/src/Lucy/Document/Doc.c
----------------------------------------------------------------------
diff --git a/c/src/Lucy/Document/Doc.c b/c/src/Lucy/Document/Doc.c
index e162839..4aa129c 100644
--- a/c/src/Lucy/Document/Doc.c
+++ b/c/src/Lucy/Document/Doc.c
@@ -36,8 +36,7 @@ Doc_init(Doc *self, void *fields, int32_t doc_id) {
     Hash *hash;
 
     if (fields) {
-        hash = (Hash *)CERTIFY(fields, HASH);
-        INCREF(hash);
+        hash = (Hash *)INCREF(CERTIFY(fields, HASH));
     }
     else {
         hash = Hash_new(0);
@@ -64,8 +63,7 @@ Doc_Get_Size_IMP(Doc *self) {
 void
 Doc_Store_IMP(Doc *self, const String *field, Obj *value) {
     Hash *hash = (Hash*)Doc_IVARS(self)->fields;
-    Hash_Store(hash, (Obj *)field, value);
-    INCREF(value);
+    Hash_Store(hash, (Obj *)field, INCREF(value));
 }
 
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/clownfish/runtime/core/Clownfish/Test/TestObj.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestObj.c b/clownfish/runtime/core/Clownfish/Test/TestObj.c
index 191ec33..4466ef0 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestObj.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestObj.c
@@ -54,7 +54,7 @@ test_refcounts(TestBatchRunner *runner) {
     TEST_INT_EQ(runner, Obj_Get_RefCount(obj), 1,
                 "Correct starting refcount");
 
-    Obj_Inc_RefCount(obj);
+    obj = Obj_Inc_RefCount(obj);
     TEST_INT_EQ(runner, Obj_Get_RefCount(obj), 2, "Inc_RefCount");
 
     Obj_Dec_RefCount(obj);

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/clownfish/runtime/core/Clownfish/Test/TestVArray.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/Test/TestVArray.c b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
index d22cad0..1abb89e 100644
--- a/clownfish/runtime/core/Clownfish/Test/TestVArray.c
+++ b/clownfish/runtime/core/Clownfish/Test/TestVArray.c
@@ -88,7 +88,7 @@ test_Store_Fetch(TestBatchRunner *runner) {
     TEST_INT_EQ(runner, 3, VA_Get_Size(array), "Store updates size");
     TEST_TRUE(runner, Str_Equals_Utf8(elem, "foo", 3), "Store");
 
-    INCREF(elem);
+    elem = (String*)INCREF(elem);
     TEST_INT_EQ(runner, 2, Str_Get_RefCount(elem),
                 "start with refcount of 2");
     VA_Store(array, 2, (Obj*)Str_newf("bar"));

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
----------------------------------------------------------------------
diff --git a/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c b/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
index 0e81e04..72cebf2 100644
--- a/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
+++ b/clownfish/runtime/core/Clownfish/TestHarness/TestBatchRunner.c
@@ -80,8 +80,7 @@ TestBatchRunner_Run_Batch_IMP(TestBatchRunner *self, TestBatch *batch) {
     if (err) {
         failed = true;
         String *mess = Err_Get_Mess(err);
-        INCREF(mess);
-        Err_warn_mess(mess);
+        Err_warn_mess((String*)INCREF(mess));
     }
     if (self->num_failed > 0) {
         failed = true;

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/LexIndex.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/LexIndex.c b/core/Lucy/Index/LexIndex.c
index 3ef77b2..f8a2a82 100644
--- a/core/Lucy/Index/LexIndex.c
+++ b/core/Lucy/Index/LexIndex.c
@@ -62,7 +62,7 @@ LexIndex_init(LexIndex *self, Schema *schema, Folder *folder,
         DECREF(self);
         Err_throw_mess(ERR, mess);
     }
-    INCREF(ivars->field_type);
+    ivars->field_type = (FieldType*)INCREF(ivars->field_type);
     ivars->term_stepper = FType_Make_Term_Stepper(ivars->field_type);
     ivars->ixix_in = Folder_Open_In(folder, ixix_file);
     if (!ivars->ixix_in) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/Snapshot.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Snapshot.c b/core/Lucy/Index/Snapshot.c
index fd9f546..3f32465 100644
--- a/core/Lucy/Index/Snapshot.c
+++ b/core/Lucy/Index/Snapshot.c
@@ -128,10 +128,9 @@ Snapshot_Read_File_IMP(Snapshot *self, Folder *folder, const String *path)
{
         }
 
         // Build up list of entries.
-        VArray *list = (VArray*)CERTIFY(
+        VArray *list = (VArray*)INCREF(CERTIFY(
                            Hash_Fetch_Utf8(snap_data, "entries", 7),
-                           VARRAY);
-        INCREF(list);
+                           VARRAY));
         if (format == 1 || (format == 2 && subformat < 1)) {
             VArray *cleaned = S_clean_segment_contents(list);
             DECREF(list);

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/SortReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortReader.c b/core/Lucy/Index/SortReader.c
index 28b55f0..efbd994 100644
--- a/core/Lucy/Index/SortReader.c
+++ b/core/Lucy/Index/SortReader.c
@@ -90,16 +90,15 @@ DefSortReader_init(DefaultSortReader *self, Schema *schema, Folder *folder,
                                     HASH));
         ivars->null_ords = (Hash*)Hash_Fetch_Utf8(metadata, "null_ords", 9);
         if (ivars->null_ords) {
-            CERTIFY(ivars->null_ords, HASH);
-            INCREF(ivars->null_ords);
+            ivars->null_ords = (Hash*)INCREF(CERTIFY(ivars->null_ords, HASH));
         }
         else {
             ivars->null_ords = Hash_new(0);
         }
         ivars->ord_widths = (Hash*)Hash_Fetch_Utf8(metadata, "ord_widths", 10);
         if (ivars->ord_widths) {
-            CERTIFY(ivars->ord_widths, HASH);
-            INCREF(ivars->ord_widths);
+            ivars->ord_widths
+                = (Hash*)INCREF(CERTIFY(ivars->ord_widths, HASH));
         }
         else {
             ivars->ord_widths = Hash_new(0);

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Index/ZombieKeyedHash.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/ZombieKeyedHash.c b/core/Lucy/Index/ZombieKeyedHash.c
index 2747888..c991e66 100644
--- a/core/Lucy/Index/ZombieKeyedHash.c
+++ b/core/Lucy/Index/ZombieKeyedHash.c
@@ -99,7 +99,7 @@ ZKHash_Make_Key_IMP(ZombieKeyedHash *self, Obj *key, int32_t hash_sum) {
      * reaches 4.  However, we must never call Destroy() for these objects,
      * because they will try to free() their initial allocation, which is
      * invalid because it's part of a MemoryPool arena. */
-    INCREF(retval);
+    retval = INCREF(retval);
 
     return retval;
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/6f3f7525/core/Lucy/Search/QueryParser/ParserElem.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/QueryParser/ParserElem.c b/core/Lucy/Search/QueryParser/ParserElem.c
index febc56f..9a831df 100644
--- a/core/Lucy/Search/QueryParser/ParserElem.c
+++ b/core/Lucy/Search/QueryParser/ParserElem.c
@@ -44,9 +44,9 @@ ParserElem_Destroy_IMP(ParserElem *self) {
 void
 ParserElem_Set_Value_IMP(ParserElem *self, Obj *value) {
     ParserElemIVARS *const ivars = ParserElem_IVARS(self);
-    INCREF(value);
+    Obj *new_value = INCREF(value);
     DECREF(ivars->value);
-    ivars->value = value;
+    ivars->value = new_value;
 }
 
 Obj*


Mime
View raw message