Skip to content

[Bugfix] Sort network mounts alphabetically#3695

Open
xavierjurado wants to merge 1 commit intolinuxmint:masterfrom
xavierjurado:bugfix/3687-sidebar-network-sort
Open

[Bugfix] Sort network mounts alphabetically#3695
xavierjurado wants to merge 1 commit intolinuxmint:masterfrom
xavierjurado:bugfix/3687-sidebar-network-sort

Conversation

@xavierjurado
Copy link

This is a fix for #3687, sorting network mounts alphabetically in the sidebar.

I didn't find any contributing guidelines in the repository, so please advice if something isn't quite right.

Before After
image image

sort_mounts_func(gconstpointer a,
gconstpointer b)
{
g_autofree gchar *name_a, *name_b = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g_autofree can only be used on one variable at a time - you need to declare name_a and name_b on separate lines, or else name_b won't get freed automatically.

g_autofree gchar *name_a = NULL;
g_autofree gchar *name_b = NULL;

though they don't necessarily need to initialize to NULL - in a simple function like this I think it's ok to combine it with the assignment below:

g_autofree gchar *name_a = g_mount_get_name (G_MOUNT(a));
g_autofree gchar *name_b = g_mount_get_name (G_MOUNT(b));

The important thing is making sure these get some sort of value before the function exits, for autofree not to crash.

Also, please keep a space between function name and opening parentheses in all changes:

// good
return g_utf8_collate (name_a, name_b);
// bad
return g_utf8_collate(name_a, name_b);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants