Use more g_autofoo throughout mutter
This commit is contained in:
parent
4a968c3b4e
commit
4d80a4cc31
5 changed files with 42 additions and 119 deletions
|
@ -886,14 +886,14 @@ apply_configuration (MetaMonitorConfig *self,
|
|||
MetaConfiguration *config,
|
||||
MetaMonitorManager *manager)
|
||||
{
|
||||
GPtrArray *crtcs, *outputs;
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GPtrArray) crtcs = NULL;
|
||||
g_autoptr(GPtrArray) outputs = NULL;
|
||||
|
||||
crtcs = g_ptr_array_new_full (config->n_outputs, (GDestroyNotify)meta_crtc_info_free);
|
||||
outputs = g_ptr_array_new_full (config->n_outputs, (GDestroyNotify)meta_output_info_free);
|
||||
|
||||
if (!meta_monitor_config_assign_crtcs (config, manager, crtcs, outputs))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
meta_monitor_manager_apply_configuration (manager,
|
||||
(MetaCRTCInfo**)crtcs->pdata, crtcs->len,
|
||||
|
@ -905,12 +905,7 @@ apply_configuration (MetaMonitorConfig *self,
|
|||
* inside turn_off_laptop_display / apply_configuration_with_lid */
|
||||
self->current_is_for_laptop_lid = FALSE;
|
||||
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
g_ptr_array_unref (crtcs);
|
||||
g_ptr_array_unref (outputs);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1840,7 +1835,6 @@ real_assign_crtcs (CrtcAssignment *assignment,
|
|||
MetaOutputKey *output_key;
|
||||
MetaOutputConfig *output_config;
|
||||
unsigned int i;
|
||||
gboolean success;
|
||||
|
||||
if (output_num == assignment->config->n_outputs)
|
||||
return TRUE;
|
||||
|
@ -1857,8 +1851,6 @@ real_assign_crtcs (CrtcAssignment *assignment,
|
|||
&crtcs, &n_crtcs,
|
||||
&outputs, &n_outputs);
|
||||
|
||||
success = FALSE;
|
||||
|
||||
for (i = 0; i < n_crtcs; i++)
|
||||
{
|
||||
MetaCRTC *crtc = &crtcs[i];
|
||||
|
@ -1905,10 +1897,7 @@ real_assign_crtcs (CrtcAssignment *assignment,
|
|||
output))
|
||||
{
|
||||
if (real_assign_crtcs (assignment, output_num + 1))
|
||||
{
|
||||
success = TRUE;
|
||||
goto out;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
crtc_assignment_unassign (assignment, crtc, output);
|
||||
}
|
||||
|
@ -1917,8 +1906,7 @@ real_assign_crtcs (CrtcAssignment *assignment,
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
return success;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
@ -368,16 +368,14 @@ static char *
|
|||
make_display_name (MetaMonitorManager *manager,
|
||||
MetaOutput *output)
|
||||
{
|
||||
char *inches = NULL;
|
||||
char *vendor_name = NULL;
|
||||
char *ret;
|
||||
g_autofree char *inches = NULL;
|
||||
g_autofree char *vendor_name = NULL;
|
||||
|
||||
switch (output->connector_type)
|
||||
{
|
||||
case META_CONNECTOR_TYPE_LVDS:
|
||||
case META_CONNECTOR_TYPE_eDP:
|
||||
ret = g_strdup (_("Built-in display"));
|
||||
goto out;
|
||||
return g_strdup (_("Built-in display"));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -413,18 +411,12 @@ make_display_name (MetaMonitorManager *manager,
|
|||
/* TRANSLATORS: this is a monitor vendor name, followed by a
|
||||
* size in inches, like 'Dell 15"'
|
||||
*/
|
||||
ret = g_strdup_printf (_("%s %s"), vendor_name, inches);
|
||||
return g_strdup_printf (_("%s %s"), vendor_name, inches);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = g_strdup (vendor_name);
|
||||
return g_strdup (vendor_name);
|
||||
}
|
||||
|
||||
out:
|
||||
g_free (inches);
|
||||
g_free (vendor_name);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
|
@ -130,9 +130,8 @@ take_device (Login1Session *session_proxy,
|
|||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
GVariant *fd_variant = NULL;
|
||||
GUnixFDList *fd_list = NULL;
|
||||
g_autoptr (GVariant) fd_variant = NULL;
|
||||
g_autoptr (GUnixFDList) fd_list = NULL;
|
||||
int fd = -1;
|
||||
|
||||
if (!login1_session_call_take_device_sync (session_proxy,
|
||||
|
@ -144,21 +143,14 @@ take_device (Login1Session *session_proxy,
|
|||
&fd_list,
|
||||
cancellable,
|
||||
error))
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
fd = g_unix_fd_list_get (fd_list, g_variant_get_handle (fd_variant), error);
|
||||
if (fd == -1)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
*out_fd = fd;
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
if (fd_variant)
|
||||
g_variant_unref (fd_variant);
|
||||
if (fd_list)
|
||||
g_object_unref (fd_list);
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -166,22 +158,16 @@ get_device_info_from_path (const char *path,
|
|||
int *out_major,
|
||||
int *out_minor)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int r;
|
||||
struct stat st;
|
||||
|
||||
r = stat (path, &st);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
if (!S_ISCHR (st.st_mode))
|
||||
goto out;
|
||||
if (r < 0 || !S_ISCHR (st.st_mode))
|
||||
return FALSE;
|
||||
|
||||
*out_major = major (st.st_rdev);
|
||||
*out_minor = minor (st.st_rdev);
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -189,22 +175,16 @@ get_device_info_from_fd (int fd,
|
|||
int *out_major,
|
||||
int *out_minor)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
int r;
|
||||
struct stat st;
|
||||
|
||||
r = fstat (fd, &st);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
if (!S_ISCHR (st.st_mode))
|
||||
goto out;
|
||||
if (r < 0 || !S_ISCHR (st.st_mode))
|
||||
return FALSE;
|
||||
|
||||
*out_major = major (st.st_rdev);
|
||||
*out_minor = minor (st.st_rdev);
|
||||
ret = TRUE;
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -194,11 +194,10 @@ static gboolean
|
|||
output_get_boolean_property (MetaMonitorManagerXrandr *manager_xrandr,
|
||||
MetaOutput *output, const char *propname)
|
||||
{
|
||||
gboolean value = FALSE;
|
||||
Atom atom, actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *buffer;
|
||||
g_autofree unsigned char *buffer = NULL;
|
||||
|
||||
atom = XInternAtom (manager_xrandr->xdisplay, propname, False);
|
||||
XRRGetOutputProperty (manager_xrandr->xdisplay,
|
||||
|
@ -209,13 +208,9 @@ output_get_boolean_property (MetaMonitorManagerXrandr *manager_xrandr,
|
|||
&nitems, &bytes_after, &buffer);
|
||||
|
||||
if (actual_type != XA_CARDINAL || actual_format != 32 || nitems < 1)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
value = ((int*)buffer)[0];
|
||||
|
||||
out:
|
||||
XFree (buffer);
|
||||
return value;
|
||||
return ((int*)buffer)[0];
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -229,12 +224,11 @@ static gboolean
|
|||
output_get_underscanning_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
||||
MetaOutput *output)
|
||||
{
|
||||
gboolean value = FALSE;
|
||||
Atom atom, actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *buffer;
|
||||
char *str;
|
||||
g_autofree unsigned char *buffer = NULL;
|
||||
g_autofree char *str = NULL;
|
||||
|
||||
atom = XInternAtom (manager_xrandr->xdisplay, "underscan", False);
|
||||
XRRGetOutputProperty (manager_xrandr->xdisplay,
|
||||
|
@ -244,17 +238,11 @@ output_get_underscanning_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
|||
&actual_type, &actual_format,
|
||||
&nitems, &bytes_after, &buffer);
|
||||
|
||||
if (actual_type != XA_ATOM || actual_format != 32 ||
|
||||
nitems < 1)
|
||||
goto out;
|
||||
if (actual_type != XA_ATOM || actual_format != 32 || nitems < 1)
|
||||
return FALSE;
|
||||
|
||||
str = XGetAtomName (manager_xrandr->xdisplay, *(Atom *)buffer);
|
||||
value = !strcmp(str, "on");
|
||||
XFree (str);
|
||||
|
||||
out:
|
||||
XFree (buffer);
|
||||
return value;
|
||||
return (strcmp (str, "on") == 0);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -273,7 +261,7 @@ output_get_backlight_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
|||
Atom atom, actual_type;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *buffer;
|
||||
g_autofree unsigned char *buffer = NULL;
|
||||
|
||||
atom = XInternAtom (manager_xrandr->xdisplay, "Backlight", False);
|
||||
XRRGetOutputProperty (manager_xrandr->xdisplay,
|
||||
|
@ -284,12 +272,9 @@ output_get_backlight_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
|||
&nitems, &bytes_after, &buffer);
|
||||
|
||||
if (actual_type != XA_INTEGER || actual_format != 32 || nitems < 1)
|
||||
goto out;
|
||||
return FALSE;
|
||||
|
||||
value = ((int*)buffer)[0];
|
||||
|
||||
out:
|
||||
XFree (buffer);
|
||||
if (value > 0)
|
||||
return normalize_backlight (output, value);
|
||||
else
|
||||
|
@ -302,7 +287,7 @@ output_get_backlight_limits_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
|||
{
|
||||
Atom atom;
|
||||
xcb_connection_t *xcb_conn;
|
||||
xcb_randr_query_output_property_reply_t *reply;
|
||||
g_autofree xcb_randr_query_output_property_reply_t *reply;
|
||||
|
||||
atom = XInternAtom (manager_xrandr->xdisplay, "Backlight", False);
|
||||
|
||||
|
@ -320,15 +305,12 @@ output_get_backlight_limits_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
|
|||
if (!reply->range || reply->length != 2)
|
||||
{
|
||||
meta_verbose ("backlight %s was not range\n", output->name);
|
||||
goto out;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t *values = xcb_randr_query_output_property_valid_values (reply);
|
||||
output->backlight_min = values[0];
|
||||
output->backlight_max = values[1];
|
||||
|
||||
out:
|
||||
free (reply);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -479,11 +461,10 @@ static MetaConnectorType
|
|||
output_get_connector_type_from_prop (MetaMonitorManagerXrandr *manager_xrandr,
|
||||
MetaOutput *output)
|
||||
{
|
||||
MetaConnectorType ret = META_CONNECTOR_TYPE_Unknown;
|
||||
Atom atom, actual_type, connector_type_atom;
|
||||
int actual_format;
|
||||
unsigned long nitems, bytes_after;
|
||||
unsigned char *buffer;
|
||||
g_autofree unsigned char *buffer = NULL;
|
||||
|
||||
atom = XInternAtom (manager_xrandr->xdisplay, "ConnectorType", False);
|
||||
XRRGetOutputProperty (manager_xrandr->xdisplay,
|
||||
|
@ -494,14 +475,10 @@ output_get_connector_type_from_prop (MetaMonitorManagerXrandr *manager_xrandr,
|
|||
&nitems, &bytes_after, &buffer);
|
||||
|
||||
if (actual_type != XA_ATOM || actual_format != 32 || nitems < 1)
|
||||
goto out;
|
||||
return META_CONNECTOR_TYPE_Unknown;
|
||||
|
||||
connector_type_atom = ((Atom *) buffer)[0];
|
||||
ret = connector_type_from_atom (manager_xrandr, connector_type_atom);
|
||||
|
||||
out:
|
||||
meta_XFree (buffer);
|
||||
return ret;
|
||||
return connector_type_from_atom (manager_xrandr, connector_type_atom);
|
||||
}
|
||||
|
||||
static MetaConnectorType
|
||||
|
@ -1068,7 +1045,7 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
|
|||
if (crtc_info->mode != NULL)
|
||||
{
|
||||
MetaMonitorMode *mode;
|
||||
XID *outputs;
|
||||
g_autofree XID *outputs = NULL;
|
||||
unsigned int j, n_outputs;
|
||||
int width, height;
|
||||
Status ok;
|
||||
|
@ -1105,7 +1082,7 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
|
|||
(unsigned)(crtc->crtc_id), (unsigned)(mode->mode_id),
|
||||
mode->width, mode->height, (float)mode->refresh_rate,
|
||||
crtc_info->x, crtc_info->y, crtc_info->transform);
|
||||
goto next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (meta_monitor_transform_is_rotated (crtc_info->transform))
|
||||
|
@ -1125,9 +1102,6 @@ meta_monitor_manager_xrandr_apply_configuration (MetaMonitorManager *manager,
|
|||
crtc->rect.height = height;
|
||||
crtc->current_mode = mode;
|
||||
crtc->transform = crtc_info->transform;
|
||||
|
||||
next:
|
||||
g_free (outputs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,6 @@ static gboolean
|
|||
accelerator_parse (const gchar *accelerator,
|
||||
MetaKeyCombo *combo)
|
||||
{
|
||||
gboolean error = FALSE;
|
||||
guint keyval, keycode;
|
||||
MetaVirtualModifier mods;
|
||||
gint len;
|
||||
|
@ -186,10 +185,7 @@ accelerator_parse (const gchar *accelerator,
|
|||
combo->modifiers = 0;
|
||||
|
||||
if (accelerator == NULL)
|
||||
{
|
||||
error = TRUE;
|
||||
goto out;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
keyval = 0;
|
||||
keycode = 0;
|
||||
|
@ -310,10 +306,7 @@ accelerator_parse (const gchar *accelerator,
|
|||
g_free (with_xf86);
|
||||
|
||||
if (keyval == XKB_KEY_NoSymbol)
|
||||
{
|
||||
error = TRUE;
|
||||
goto out;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,14 +315,10 @@ accelerator_parse (const gchar *accelerator,
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (error)
|
||||
return FALSE;
|
||||
|
||||
out:
|
||||
combo->keysym = keyval;
|
||||
combo->keycode = keycode;
|
||||
combo->modifiers = mods;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue