Do not check the return value of para_printf().
[paraslash.git] / attribute.c
index e73a0e76db5d9ed4052480bb89d360d44d57dc91..435f22b5aed560f134aae6b2c9520789c39c3b36 100644 (file)
@@ -135,15 +135,18 @@ static int print_attribute(struct osl_table *table, struct osl_row *row,
        struct osl_object bitnum_obj;
        int ret;
 
-       if (!(laad->flags & LSATT_FLAG_LONG))
-               return para_printf(&laad->pb, "%s\n", name);
+       if (!(laad->flags & LSATT_FLAG_LONG)) {
+               para_printf(&laad->pb, "%s\n", name);
+               return 1;
+       }
        ret = osl(osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj));
        if (ret < 0) {
                para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret));
                return ret;
        }
-       return para_printf(&laad->pb, "%u\t%s\n", *(unsigned char*)bitnum_obj.data,
+       para_printf(&laad->pb, "%u\t%s\n", *(unsigned char*)bitnum_obj.data,
                name);
+       return 1;
 }
 
 static void com_lsatt_callback(int fd, const struct osl_object *query)
@@ -225,7 +228,7 @@ struct addatt_event_data {
 static void com_addatt_callback(int fd, const struct osl_object *query)
 {
        char *p;
-       int ret = 1, ret2 = 0;
+       int ret = 1;
        struct para_buffer pb = {
                .max_size = shm_get_shmmax(),
                .private_data = &(struct afs_max_size_handler_data) {
@@ -244,16 +247,12 @@ static void com_addatt_callback(int fd, const struct osl_object *query)
 
                len = strlen(p);
                if (!len || p[len - 1] == '-' || p[len - 1] == '+') {
-                       ret2 = para_printf(&pb, "invalid attribute name: %s\n", p);
-                       if (ret2 < 0)
-                               goto out;
+                       para_printf(&pb, "invalid attribute name: %s\n", p);
                        continue;
                }
                ret = get_attribute_bitnum_by_name(p, &bitnum);
                if (ret >= 0) {
-                       ret2 = para_printf(&pb, "attribute \"%s\" already exists\n", p);
-                       if (ret2 < 0)
-                               goto out;
+                       para_printf(&pb, "attribute \"%s\" already exists\n", p);
                        continue;
                }
                if (ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) /* error */
@@ -285,7 +284,7 @@ static void com_addatt_callback(int fd, const struct osl_object *query)
                greatest_att_bitnum = PARA_MAX(greatest_att_bitnum, (int)bitnum);
        }
 out:
-       if (ret < 0 && ret2 >= 0)
+       if (ret < 0)
                para_printf(&pb, "%s: %s\n", p, para_strerror(-ret));
        if (pb.offset)
                pass_buffer_as_shm(fd, SBD_OUTPUT, pb.buf, pb.offset);
@@ -361,6 +360,7 @@ struct remove_attribute_action_data {
        uint64_t mask_of_removed_atts;
 };
 
+/* returns succcess even on errors to keep the loop going */
 static int remove_attribute(struct osl_table *table, struct osl_row *row,
                const char *name, void *data)
 {
@@ -369,16 +369,20 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row,
        struct rmatt_event_data red = {.name = name};
 
        ret = get_attribute_bitnum_by_name(name, &red.bitnum);
-       if (ret < 0)
-               return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
+       if (ret < 0) {
+               para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
+               return 0;
+       }
        ret = osl(osl_del_row(table, row));
-       if (ret < 0)
-               return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
-       ret = para_printf(&raad->pb, "removed attribute %s\n", name);
+       if (ret < 0) {
+               para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret));
+               return 0;
+       }
+       para_printf(&raad->pb, "removed attribute %s\n", name);
        raad->num_removed++;
        raad->mask_of_removed_atts |= (1 << red.bitnum);
        afs_event(ATTRIBUTE_REMOVE, &raad->pb, &red);
-       return ret;
+       return 1;
 }
 
 static void com_rmatt_callback(int fd, const struct osl_object *query)
@@ -394,7 +398,7 @@ static void com_rmatt_callback(int fd, const struct osl_object *query)
                        .max_size_handler = afs_max_size_handler,
                }
        };
-       int ret, ret2 = 0;
+       int ret;
        struct pattern_match_data pmd = {
                .table = attribute_table,
                .patterns = *query,
@@ -405,10 +409,10 @@ static void com_rmatt_callback(int fd, const struct osl_object *query)
        };
        ret = for_each_matching_row(&pmd);
        if (ret < 0)
-               ret2 = para_printf(&raad.pb, "%s\n", para_strerror(-ret));
+               para_printf(&raad.pb, "%s\n", para_strerror(-ret));
        else if (!raad.num_removed)
-               ret2 = para_printf(&raad.pb, "no match -- nothing removed\n");
-       if (ret2 >= 0 && raad.pb.offset)
+               para_printf(&raad.pb, "no match -- nothing removed\n");
+       if (raad.pb.offset)
                pass_buffer_as_shm(fd, SBD_OUTPUT, raad.pb.buf, raad.pb.offset);
        free(raad.pb.buf);
 }