Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gnome-bluetooth
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
38
Issues
38
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
gnome-bluetooth
Commits
3948b2ae
Commit
3948b2ae
authored
Dec 09, 2020
by
Bastien Nocera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
settings-widget: Simplify sorting function
Use g_autofree to get rid of a number of gotos.
parent
81bc7d8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
22 deletions
+11
-22
lib/bluetooth-settings-widget.c
lib/bluetooth-settings-widget.c
+11
-22
No files found.
lib/bluetooth-settings-widget.c
View file @
3948b2ae
...
...
@@ -1406,8 +1406,8 @@ device_sort_func (gconstpointer a, gconstpointer b, gpointer data)
gboolean
paired_a
,
paired_b
;
gboolean
trusted_a
,
trusted_b
;
gboolean
connected_a
,
connected_b
;
char
*
name_a
,
*
name_b
;
int
ret
;
g_autofree
char
*
name_a
=
NULL
;
g_autofree
char
*
name_b
=
NULL
;
g_object_get
(
row_a
,
"paired"
,
&
paired_a
,
...
...
@@ -1427,37 +1427,26 @@ device_sort_func (gconstpointer a, gconstpointer b, gpointer data)
setup_b
=
paired_b
||
trusted_b
;
if
(
setup_a
!=
setup_b
)
{
if
(
setup_a
)
ret
=
-
1
;
ret
urn
-
1
;
else
ret
=
1
;
goto
out
;
return
1
;
}
/* Then connected ones */
if
(
connected_a
!=
connected_b
)
{
if
(
connected_a
)
ret
=
-
1
;
ret
urn
-
1
;
else
ret
=
1
;
goto
out
;
return
1
;
}
if
(
name_a
==
NULL
)
{
ret
=
1
;
goto
out
;
}
if
(
name_b
==
NULL
)
{
ret
=
-
1
;
goto
out
;
}
if
(
name_a
==
NULL
)
return
1
;
if
(
name_b
==
NULL
)
return
-
1
;
/* And all being equal, alphabetically */
ret
=
g_utf8_collate
(
name_a
,
name_b
);
out:
g_free
(
name_a
);
g_free
(
name_b
);
return
ret
;
return
g_utf8_collate
(
name_a
,
name_b
);
}
static
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment