lib/kargs: allow empty-list arguments
This adds support for empty-list arguments (e.g. `acpi_osi=`), which are semantically different from simple-keyword arguments. Ref: https://github.com/projectatomic/rpm-ostree/issues/1706 Closes: #1785 Approved by: cgwalters
This commit is contained in:
1 parent
d044bfeb30
commit
3ecbdd8197
2 files changed
+17
-26
No files matched your search
@@ -33,23 +33,14 @@ static char *
|
||||
split_keyeq (char *arg)
|
||||
{
|
||||
char *eq;
|
||||
|
||||
|
||||
eq = strchr (arg, '=');
|
||||
if (eq)
|
||||
{
|
||||
/* Note key/val are in one malloc block,
|
||||
* so we don't free val...
|
||||
*/
|
||||
*eq = '\0';
|
||||
return eq+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ...and this allows us to insert a constant
|
||||
* string.
|
||||
*/
|
||||
return "";
|
||||
}
|
||||
if (eq == NULL)
|
||||
return NULL;
|
||||
|
||||
// Note: key/val are in a single allocation block, so we don't free val.
|
||||
*eq = '\0';
|
||||
return eq+1;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -264,8 +255,10 @@ _ostree_kernel_args_to_strv (OstreeKernelArgs *kargs)
|
||||
for (j = 0; j < values->len; j++)
|
||||
{
|
||||
const char *value = values->pdata[j];
|
||||
|
||||
g_ptr_array_add (strv, g_strconcat (key, "=", value, NULL));
|
||||
if (value == NULL)
|
||||
g_ptr_array_add (strv, g_strconcat (key, NULL));
|
||||
else
|
||||
g_ptr_array_add (strv, g_strconcat (key, "=", value, NULL));
|
||||
}
|
||||
}
|
||||
g_ptr_array_add (strv, NULL);
|
||||
@@ -297,14 +290,12 @@ _ostree_kernel_args_to_string (OstreeKernelArgs *kargs)
|
||||
else
|
||||
g_string_append_c (buf, ' ');
|
||||
|
||||
if (value && *value)
|
||||
g_string_append (buf, key);
|
||||
if (value != NULL)
|
||||
{
|
||||
g_string_append (buf, key);
|
||||
g_string_append_c (buf, '=');
|
||||
g_string_append (buf, value);
|
||||
}
|
||||
else
|
||||
g_string_append (buf, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user