com_setatt(): Use get_attribute_bitnum_by_name().
authorAndre Noll <maan@systemlinux.org>
Mon, 22 Jul 2013 18:36:58 +0000 (20:36 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 10 Aug 2013 14:03:43 +0000 (16:03 +0200)
We have this nice helper, so don't open-code it.

attribute.c

index 96b54c9..a28de63 100644 (file)
@@ -226,10 +226,10 @@ static void com_setatt_callback(__a_unused int fd, const struct osl_object *quer
        int ret;
        size_t len;
        struct osl_object obj;
-       struct osl_row *row;
 
        for (p = query->data; p < (char *)query->data + query->size; p += len + 1) {
                char c;
+               unsigned char bitnum;
 
                len = strlen(p);
                ret = -E_ATTR_SYNTAX;
@@ -239,19 +239,13 @@ static void com_setatt_callback(__a_unused int fd, const struct osl_object *quer
                if (c != '+' && c != '-')
                        break;
                p[len - 1] = '\0';
-               obj.data = p;
-               obj.size = len + 1;
-               ret = osl(osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row));
-               if (ret < 0)
-                       goto out;
-               ret = osl(osl_get_object(attribute_table, row, ATTCOL_BITNUM,
-                       &obj));
+               ret = get_attribute_bitnum_by_name(p, &bitnum);
                if (ret < 0)
                        goto out;
                if (c == '+')
-                       add_mask |= (1UL << *(unsigned char *)obj.data);
+                       add_mask |= (1UL << bitnum);
                else
-                       del_mask |= (1UL << *(unsigned char *)obj.data);
+                       del_mask |= (1UL << bitnum);
        }
        ret = -E_ATTR_SYNTAX;
        if (!add_mask && !del_mask)