As per pull request review. Moving the variable assignement after
the check avoid any potential issues in the future.
Signed-off-by: Francesco Romani <fromani@redhat.com>
static int lv_read(user_data_t *ud) {
time_t t;
- struct lv_read_instance *inst = ud->data;
- struct lv_read_state *state = &inst->read_state;
- if (!inst) {
+ struct lv_read_instance *inst = NULL;
+ struct lv_read_state *state = NULL;
+ if (ud->data == NULL) {
ERROR(PLUGIN_NAME " plugin: NULL userdata");
return -1;
}
+ inst = ud->data;
+ state = &inst->read_state;
+
if (inst->id == 0 && conn == NULL) {
/* `conn_string == NULL' is acceptable. */
conn = virConnectOpenReadOnly(conn_string);