From: Andreas Steffen Date: Wed, 4 Sep 2013 19:56:25 +0000 (+0200) Subject: swid_inventory object has a get_count method X-Git-Tag: 5.1.1dr3~8 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=b28686d530a9a64649e577f74482eec9940ae5b0;p=thirdparty%2Fstrongswan.git swid_inventory object has a get_count method --- diff --git a/src/libpts/plugins/imc_swid/imc_swid.c b/src/libpts/plugins/imc_swid/imc_swid.c index 6ad84dce65..ed6dd8b407 100644 --- a/src/libpts/plugins/imc_swid/imc_swid.c +++ b/src/libpts/plugins/imc_swid/imc_swid.c @@ -187,6 +187,9 @@ static TNC_Result receive_message(imc_state_t *state, imc_msg_t *in_msg) out_msg->add_attribute(out_msg, attr); break; } + DBG1(DBG_IMC, "collected %d SWID tag%s%s", + swid_inventory->get_count(swid_inventory), full_tags ? "" : " ID", + swid_inventory->get_count(swid_inventory) == 1 ? "" : "s"); if (full_tags) { diff --git a/src/libpts/swid/swid_inventory.c b/src/libpts/swid/swid_inventory.c index 239ea9f92d..9a33018af9 100644 --- a/src/libpts/swid/swid_inventory.c +++ b/src/libpts/swid/swid_inventory.c @@ -54,8 +54,7 @@ struct private_swid_inventory_t { linked_list_t *list; }; -static bool collect_tags(private_swid_inventory_t *this, char *pathname, - int *tag_count) +static bool collect_tags(private_swid_inventory_t *this, char *pathname) { char *rel_name, *abs_name; struct stat st; @@ -83,7 +82,7 @@ static bool collect_tags(private_swid_inventory_t *this, char *pathname, } if (S_ISDIR(st.st_mode)) { - if (!collect_tags(this, abs_name, tag_count)) + if (!collect_tags(this, abs_name)) { goto end; } @@ -168,7 +167,6 @@ static bool collect_tags(private_swid_inventory_t *this, char *pathname, tag_id = swid_tag_id_create(tag_creator, unique_sw_id, unique_seq_id); this->list->insert_last(this->list, tag_id); } - (*tag_count)++; } success = TRUE; @@ -183,18 +181,7 @@ end: METHOD(swid_inventory_t, collect, bool, private_swid_inventory_t *this) { - int tag_count = 0; - - if (collect_tags(this, SWID_TAG_DIRECTORY, &tag_count)) - { - DBG1(DBG_IMC, "collected %d SWID tag%s%s", tag_count, - this->full_tags ? "" : " ID", (tag_count == 1) ? "" : "s"); - return TRUE; - } - else - { - return FALSE; - } + return collect_tags(this, SWID_TAG_DIRECTORY); } METHOD(swid_inventory_t, add, void,