mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-05 11:08:01 +02:00
ppd-driver: Use NULL values if values are unset
This commit is contained in:
parent
05cea66718
commit
b88875c550
2 changed files with 22 additions and 10 deletions
|
|
@ -130,19 +130,25 @@ get_active_profile (PpdApp *data)
|
|||
static char *
|
||||
get_performance_degraded (PpdApp *data)
|
||||
{
|
||||
const gchar *cpu_degraded = "";
|
||||
const gchar *platform_degraded = "";
|
||||
const gchar *cpu_degraded = NULL;
|
||||
const gchar *platform_degraded = NULL;
|
||||
|
||||
if (driver_profile_support (PPD_DRIVER (data->platform_driver), PPD_PROFILE_PERFORMANCE))
|
||||
platform_degraded = ppd_driver_get_performance_degraded (PPD_DRIVER (data->platform_driver));
|
||||
|
||||
if (driver_profile_support (PPD_DRIVER (data->cpu_driver), PPD_PROFILE_PERFORMANCE))
|
||||
cpu_degraded = ppd_driver_get_performance_degraded (PPD_DRIVER (data->cpu_driver));
|
||||
|
||||
if (g_strcmp0 (cpu_degraded, "") == 0)
|
||||
return g_strdup(platform_degraded);
|
||||
if (g_strcmp0 (platform_degraded, "") == 0)
|
||||
return g_strdup(cpu_degraded);
|
||||
return g_strdup_printf("%s,%s", cpu_degraded, platform_degraded);
|
||||
if (!cpu_degraded && !platform_degraded)
|
||||
return g_strdup ("");
|
||||
|
||||
if (!cpu_degraded)
|
||||
return g_strdup (platform_degraded);
|
||||
|
||||
if (!platform_degraded)
|
||||
return g_strdup (cpu_degraded);
|
||||
|
||||
return g_strjoin (",", cpu_degraded, platform_degraded, NULL);
|
||||
}
|
||||
|
||||
static GVariant *
|
||||
|
|
|
|||
|
|
@ -72,8 +72,14 @@ ppd_driver_set_property (GObject *object,
|
|||
priv->profiles = g_value_get_flags (value);
|
||||
break;
|
||||
case PROP_PERFORMANCE_DEGRADED:
|
||||
g_clear_pointer (&priv->performance_degraded, g_free);
|
||||
priv->performance_degraded = g_value_dup_string (value);
|
||||
{
|
||||
const char *degraded = g_value_get_string (value);
|
||||
|
||||
g_clear_pointer (&priv->performance_degraded, g_free);
|
||||
|
||||
if (degraded != NULL && *degraded != '\0')
|
||||
priv->performance_degraded = g_strdup (degraded);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
|
||||
|
|
@ -270,7 +276,7 @@ ppd_driver_get_performance_degraded (PpdDriver *driver)
|
|||
g_return_val_if_fail (PPD_IS_DRIVER (driver), NULL);
|
||||
|
||||
priv = PPD_DRIVER_GET_PRIVATE (driver);
|
||||
return priv->performance_degraded ? priv->performance_degraded : "";
|
||||
return priv->performance_degraded;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue