supplicant: rename 'hidden' argument

Sometimes the option can't be displayed as is because it contains NULL
or non-ascii characters. Rename the 'hidden' argument of
nm_supplicant_config_add_option_with_type() to 'display_value' so that
callers can pass a preferred string representation of the value.
This commit is contained in:
Beniamino Galvani
2021-01-21 09:59:14 +01:00
parent 2757da7eac
commit 18fe100926

View File

@@ -100,7 +100,7 @@ nm_supplicant_config_add_option_with_type(NMSupplicantConfig *self,
const char * value, const char * value,
gint32 len, gint32 len,
NMSupplOptType opt_type, NMSupplOptType opt_type,
const char * hidden, const char * display_value,
GError ** error) GError ** error)
{ {
NMSupplicantConfigPrivate *priv; NMSupplicantConfigPrivate *priv;
@@ -138,7 +138,7 @@ nm_supplicant_config_add_option_with_type(NMSupplicantConfig *self,
NM_SUPPLICANT_ERROR_CONFIG, NM_SUPPLICANT_ERROR_CONFIG,
"key '%s' and/or value %s invalid", "key '%s' and/or value %s invalid",
key, key,
hidden ?: str); display_value ?: str);
return FALSE; return FALSE;
} }
} }
@@ -165,7 +165,10 @@ nm_supplicant_config_add_option_with_type(NMSupplicantConfig *self,
char buf[255]; char buf[255];
memset(&buf[0], 0, sizeof(buf)); memset(&buf[0], 0, sizeof(buf));
memcpy(&buf[0], opt->value, opt->len > 254 ? 254 : opt->len); memcpy(&buf[0], opt->value, opt->len > 254 ? 254 : opt->len);
nm_log_info(LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, hidden ?: &buf[0]); nm_log_info(LOGD_SUPPLICANT,
"Config: added '%s' value '%s'",
key,
display_value ?: &buf[0]);
} }
g_hash_table_insert(priv->config, g_strdup(key), opt); g_hash_table_insert(priv->config, g_strdup(key), opt);
@@ -178,7 +181,7 @@ nm_supplicant_config_add_option(NMSupplicantConfig *self,
const char * key, const char * key,
const char * value, const char * value,
gint32 len, gint32 len,
const char * hidden, const char * display_value,
GError ** error) GError ** error)
{ {
return nm_supplicant_config_add_option_with_type(self, return nm_supplicant_config_add_option_with_type(self,
@@ -186,7 +189,7 @@ nm_supplicant_config_add_option(NMSupplicantConfig *self,
value, value,
len, len,
NM_SUPPL_OPT_TYPE_INVALID, NM_SUPPL_OPT_TYPE_INVALID,
hidden, display_value,
error); error);
} }
@@ -633,7 +636,7 @@ add_string_val(NMSupplicantConfig *self,
const char * field, const char * field,
const char * name, const char * name,
gboolean ucase, gboolean ucase,
const char * hidden, const char * display_value,
GError ** error) GError ** error)
{ {
if (field) { if (field) {
@@ -643,7 +646,12 @@ add_string_val(NMSupplicantConfig *self,
value = g_ascii_strup(field, -1); value = g_ascii_strup(field, -1);
field = value; field = value;
} }
return nm_supplicant_config_add_option(self, name, field, strlen(field), hidden, error); return nm_supplicant_config_add_option(self,
name,
field,
strlen(field),
display_value,
error);
} }
return TRUE; return TRUE;
} }
@@ -656,7 +664,7 @@ add_string_val(NMSupplicantConfig *self,
name, \ name, \
separator, \ separator, \
ucase, \ ucase, \
hidden, \ display_value, \
error) \ error) \
({ \ ({ \
typeof(*(setting)) *_setting = (setting); \ typeof(*(setting)) *_setting = (setting); \
@@ -685,7 +693,7 @@ add_string_val(NMSupplicantConfig *self,
(name), \ (name), \
_str->str, \ _str->str, \
-1, \ -1, \
(hidden), \ (display_value), \
(error))) \ (error))) \
_success = FALSE; \ _success = FALSE; \
} \ } \