Update attribute commit function 20/241920/1 accepted/tizen/6.0/unified/20201030.114356 accepted/tizen/6.0/unified/hotfix/20201103.002706 accepted/tizen/unified/20200825.033215 submit/tizen/20200821.045404 submit/tizen_6.0/20201029.205104 submit/tizen_6.0_hotfix/20201102.192504 submit/tizen_6.0_hotfix/20201103.114804 tizen_6.0.m2_release
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 21 Aug 2020 01:25:09 +0000 (10:25 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 21 Aug 2020 01:26:03 +0000 (10:26 +0900)
- Previously, mm_attrs_commit() did not call commit function of each attribute.
- In this patch, mm_attrs_commit() will invoke commit function of each attribute if existed,
  and remove duplicated code.

[Version] 0.2.122
[Issue Type] Update

Change-Id: Idf21a3750a65375651456256558c6761d969cf75
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
include/mm_attrs_private.h
mm_attrs.c
mm_attrs_private.c
packaging/libmm-common.spec

index e3a81a5..14f257c 100644 (file)
@@ -233,7 +233,9 @@ MMHandleType mmf_attrs_new_from_data(const char *name,
 
 void mmf_attrs_free(MMHandleType h);
 
-int mmf_attrs_commit(MMHandleType h);
+int mmf_attrs_commit(MMHandleType h, int idx, char **err_attr_name);
+
+int mmf_attrs_commit_all(MMHandleType h);
 
 int mmf_attrs_set_valid_type(MMHandleType h, int idx, int v_type);
 
index aba8394..fe149b2 100644 (file)
@@ -54,26 +54,12 @@ void mm_attrs_free(MMHandleType attrs)
 
 int mm_attrs_commit_all(MMHandleType attrs)
 {
-       return mmf_attrs_commit(attrs);
+       return mmf_attrs_commit_all(attrs);
 }
 
 int mm_attrs_commit(MMHandleType attrs, int index)
 {
-       mmf_attrs_t *h = (mmf_attrs_t *) attrs;
-       mmf_attribute_t *item;
-
-       return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT);
-       return_val_if_fail(index >= 0, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       item = &h->items[index];
-
-       MM_ATTR_ITEM_WRITE_LOCK(item);
-
-       mmf_attribute_commit(item);
-
-       MM_ATTR_ITEM_WRITE_UNLOCK(item);
-
-       return MM_ERROR_NONE;
+       return mmf_attrs_commit(attrs, index, NULL);
 }
 
 int mm_attrs_get_type(MMHandleType attrs, int index, MMAttrsType *attrtype)
index 1e2ddd9..ed0c096 100644 (file)
@@ -663,85 +663,74 @@ int mmf_attrs_init(MMHandleType h, mmf_attrs_construct_info_t *info, int count)
        return 0;
 }
 
-int mmf_attrs_commit(MMHandleType h)
+int mmf_attrs_commit(MMHandleType h, int idx, char **err_attr_name)
 {
        mmf_attrs_t *attrs = (mmf_attrs_t *)h;
        mmf_attribute_t *item = NULL;
-       int i;
        int ret = 0;
 
        return_val_if_fail(h, -1);
 
-       for (i = 0; i < attrs->count; ++i) {
-               item = &attrs->items[i];
+       item = &attrs->items[idx];
 
-               MM_ATTR_ITEM_WRITE_LOCK(item);
-
-               if (mmf_attribute_is_modified(item)) {
-                       if (attrs->commit_func) {
-                               if (attrs->commit_func(i, item->name,
-                                                                               &item->tmpval,
-                                                                               attrs->commit_param)) {
-                                       mmf_attribute_commit(item);
-                               } else {
-                                       /* without this, there is no way to solve modify when commit_func failed. */
-                                       if (item->flags & MM_ATTRS_FLAG_MODIFIED)
-                                               item->flags ^= MM_ATTRS_FLAG_MODIFIED;
-                                       ret = -1;
-                               }
-                       } else {
+       MM_ATTR_ITEM_WRITE_LOCK(item);
+
+       if (mmf_attribute_is_modified(item)) {
+               if (attrs->commit_func) {
+                       if (attrs->commit_func(idx,
+                               item->name,
+                               &item->tmpval,
+                               attrs->commit_param)) {
                                mmf_attribute_commit(item);
+                       } else {
+                               /* without this, there is no way to solve modify when commit_func failed. */
+                               if (item->flags & MM_ATTRS_FLAG_MODIFIED)
+                                       item->flags ^= MM_ATTRS_FLAG_MODIFIED;
+                               ret = -1;
+
+                               /* Set Error information */
+                               if (err_attr_name)
+                                       *err_attr_name = strdup(item->name);
                        }
+               } else {
+                       mmf_attribute_commit(item);
                }
-
-               MM_ATTR_ITEM_WRITE_UNLOCK(item);
        }
 
+       MM_ATTR_ITEM_WRITE_UNLOCK(item);
+
        return ret;
 }
 
-int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name)
+int mmf_attrs_commit_all(MMHandleType h)
 {
        mmf_attrs_t *attrs = (mmf_attrs_t *)h;
-       mmf_attribute_t *item = NULL;
        int i;
        int ret = 0;
 
        return_val_if_fail(h, -1);
 
        for (i = 0; i < attrs->count; ++i) {
-               item = &attrs->items[i];
+               if (mmf_attrs_commit(h, i, NULL) != 0)
+                       ret = -1;
+       }
 
-               MM_ATTR_ITEM_WRITE_LOCK(item);
-
-               if (mmf_attribute_is_modified(item)) {
-                       if (attrs->commit_func) {
-                               if (attrs->commit_func(i, item->name,
-                                                                               &item->tmpval,
-                                                                               attrs->commit_param)) {
-                                       mmf_attribute_commit(item);
-                               } else {
-                                       /* without this, there is no way to solve modify when commit_func failed. */
-                                       if (item->flags & MM_ATTRS_FLAG_MODIFIED)
-                                               item->flags ^= MM_ATTRS_FLAG_MODIFIED;
-                                       ret = -1;
-
-                                       /* Set Error information */
-                                       if (err_attr_name)
-                                               *err_attr_name = strdup(item->name);
-
-                                       MM_ATTR_ITEM_WRITE_UNLOCK(item);
-                                       break;
-                               }
-                       } else {
-                               mmf_attribute_commit(item);
-                       }
-               }
+       return ret;
+}
+
+int mmf_attrs_commit_err(MMHandleType h, char **err_attr_name)
+{
+       mmf_attrs_t *attrs = (mmf_attrs_t *)h;
+       int i;
+
+       return_val_if_fail(h, -1);
 
-               MM_ATTR_ITEM_WRITE_UNLOCK(item);
+       for (i = 0; i < attrs->count; ++i) {
+               if (mmf_attrs_commit(h, i, err_attr_name) != 0)
+                       return -1;
        }
 
-       return ret;
+       return 0;
 }
 
 int mmf_attrs_set_valid_type(MMHandleType h, int idx, int v_type)
index a186e4e..33d2ef4 100644 (file)
@@ -1,7 +1,7 @@
 Name:       libmm-common
 Summary:    Multimedia Framework Common Lib
-Version:    0.2.121
-Release:    1
+Version:    0.2.122
+Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz