diff options
author | Thomas Haller <thaller@redhat.com> | 2022-09-02 21:15:57 +0200 |
---|---|---|
committer | Wen Liang <liangwen12year@gmail.com> | 2022-09-07 10:47:35 -0400 |
commit | 61d74b0c152874eda03bc67bbb5feb85e0879e97 (patch) | |
tree | e413a6bf05546ff18fe8d9d4ab79ddbfc087ed04 | |
parent | 4c32dd9d252959b9bab5de6277418939b64d1bb1 (diff) |
ifcfg-rh: rework error handling in parse_infiniband_p_key()wl/ifcfg
-rw-r--r-- | src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c index cd5e8a9c0f..96f5969728 100644 --- a/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c +++ b/src/core/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c @@ -5355,43 +5355,41 @@ wired_connection_from_ifcfg(const char *file, shvarFile *ifcfg, GError **error) static gboolean parse_infiniband_p_key(shvarFile *ifcfg, int *out_p_key, char **out_parent, GError **error) { - char *physdev = NULL, *pkey_id = NULL; - int id; - gboolean ret = FALSE; + gs_free char *physdev = NULL; + gs_free char *pkey_id = NULL; + int id; physdev = svGetValueStr_cp(ifcfg, "PHYSDEV"); if (!physdev) { - PARSE_WARNING("InfiniBand connection specified PKEY but not PHYSDEV"); - goto done; + g_set_error(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "infiniband connection specified PKEY but not PHYSDEV"); + return FALSE; } pkey_id = svGetValueStr_cp(ifcfg, "PKEY_ID"); if (!pkey_id) { - PARSE_WARNING("InfiniBand connection specified PKEY but not PKEY_ID"); - goto done; + g_set_error(error, + NM_SETTINGS_ERROR, + NM_SETTINGS_ERROR_INVALID_CONNECTION, + "infiniband connection specified PKEY but not PKEY_ID"); + return FALSE; } id = _nm_utils_ascii_str_to_int64(pkey_id, 0, 0, 0xFFFF, -1); if (id == -1) { - PARSE_WARNING("invalid InfiniBand PKEY_ID '%s'", pkey_id); - goto done; - } - - *out_p_key = id; - *out_parent = g_strdup(physdev); - ret = TRUE; - -done: - g_free(physdev); - g_free(pkey_id); - - if (!ret) { g_set_error(error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION, - "Failed to create InfiniBand setting"); + "invalid infiniband PKEY_ID '%s'", + pkey_id); + return FALSE; } - return ret; + + *out_p_key = id; + *out_parent = g_steal_pointer(&physdev); + return TRUE; } static NMSetting * |