After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 776169 - Various gio-tool fixes
Various gio-tool fixes
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-12-16 14:02 UTC by Ondrej Holy
Modified: 2017-06-06 11:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio-tool: Various fixes related to error messages (13.54 KB, patch)
2016-12-16 14:03 UTC, Ondrej Holy
none Details | Review
gio-tool: Various memory leak fixes (2.10 KB, patch)
2016-12-16 14:03 UTC, Ondrej Holy
committed Details | Review
gio-tool: Do not print settable arguments unless they are any (1.56 KB, patch)
2016-12-16 14:03 UTC, Ondrej Holy
committed Details | Review
gio-tool: Return error if there are not any volumes to mount (937 bytes, patch)
2016-12-16 14:03 UTC, Ondrej Holy
committed Details | Review
gio-tool: Various fixes related to error messages (16.33 KB, patch)
2016-12-19 12:55 UTC, Ondrej Holy
committed Details | Review
gio-tool: Add g_drive_is_removable() support (1.12 KB, patch)
2016-12-19 12:57 UTC, Ondrej Holy
committed Details | Review
gio-tool: Do not leak GOptionContext (12.92 KB, patch)
2016-12-19 12:57 UTC, Ondrej Holy
committed Details | Review
gio-tool: Fix alignment of monitor messages (1.46 KB, patch)
2017-06-06 09:14 UTC, Ondrej Holy
committed Details | Review

Description Ondrej Holy 2016-12-16 14:02:09 UTC
I wanted to fix one wrong error message and ended up with the following patches. I hope you will like that...
Comment 1 Ondrej Holy 2016-12-16 14:03:35 UTC
Created attachment 342056 [details] [review]
gio-tool: Various fixes related to error messages

This patch contains the following changes:
- Print all errors with "gio: " prefix
- Print file uri in error for each tool allowing multiple locations
- Mark all error messages translatable
- Do not leak strings used in error messages
- Always start error messages with capital letter
- Unify some error messages across various tools
- Fix addional/missing new line characters
Comment 2 Ondrej Holy 2016-12-16 14:03:40 UTC
Created attachment 342057 [details] [review]
gio-tool: Various memory leak fixes
Comment 3 Ondrej Holy 2016-12-16 14:03:44 UTC
Created attachment 342058 [details] [review]
gio-tool: Do not print settable arguments unless they are any

"Settable arguments:" is printed even if they are not any arguments
to print. Do not print it similarly as it is done for "Writable
namespaces:".
Comment 4 Ondrej Holy 2016-12-16 14:03:49 UTC
Created attachment 342059 [details] [review]
gio-tool: Return error if there are not any volumes to mount

Print error and return error code if device doesn't contain any
volumes to mount.
Comment 5 Colin Walters 2016-12-16 15:06:47 UTC
Review of attachment 342056 [details] [review]:

OK.
Comment 6 Colin Walters 2016-12-16 15:07:27 UTC
Review of attachment 342057 [details] [review]:

I didn't look closely, but seems sane.
Comment 7 Colin Walters 2016-12-16 15:07:29 UTC
Review of attachment 342057 [details] [review]:

I didn't look closely, but seems sane.
Comment 8 Colin Walters 2016-12-16 15:07:41 UTC
Review of attachment 342058 [details] [review]:

OK.
Comment 9 Colin Walters 2016-12-16 15:07:59 UTC
Review of attachment 342059 [details] [review]:

OK.
Comment 10 Ondrej Holy 2016-12-19 12:54:18 UTC
Colin, thanks for the reviews! I wanted to fix one more issue and ended up with other patches, attaching them... :-D
Comment 11 Ondrej Holy 2016-12-19 12:54:27 UTC
Review of attachment 342056 [details] [review]:

::: gio/gio-tool-monitor.c
@@ +268,3 @@
   if (!total)
     {
+      show_help (context, _("No locations given"));

I've realized that the context is already freed at this point...
Comment 12 Ondrej Holy 2016-12-19 12:55:26 UTC
Created attachment 342214 [details] [review]
gio-tool: Various fixes related to error messages

So I've fixed the use-after-free in gio-tool-monitor and added the following changes:

@@ -151 +151 @@ handle_cat (int argc, char *argv[], gboolean do_help)
-      show_help (context, _("No files given"));
+      show_help (context, _("No locations given"));

@@ -69 +69 @@ handle_open (int argc, char *argv[], gboolean do_help)
-      show_help (context, _("No files to open"));
+      show_help (context, _("No locations given"));

@@ -70 +70 @@ handle_remove (int argc, char *argv[], gboolean do_help)
-      show_help (context, _("No files to delete"));
+      show_help (context, _("No locations given"));

I don't think we need special error messages in this cases... let's use "No locations given" which is already used at several other places.
Comment 13 Ondrej Holy 2016-12-19 12:57:12 UTC
Created attachment 342215 [details] [review]
gio-tool: Add g_drive_is_removable() support

The g_drive_is_removable() support was added recently in gio/gvfs
(see Bug 765900 and Bug 765457). It was also added in gvfs-mount,
but we forgot to add it also in gio-tool-mount.
Comment 14 Ondrej Holy 2016-12-19 12:57:31 UTC
Created attachment 342216 [details] [review]
gio-tool: Do not leak GOptionContext

GOptionContext is freed only in case of success. Free the context
also in case of failure.
Comment 15 Matthias Clasen 2017-04-08 05:08:06 UTC
Review of attachment 342214 [details] [review]:

ok
Comment 16 Matthias Clasen 2017-04-08 05:08:38 UTC
Review of attachment 342215 [details] [review]:

sure
Comment 17 Matthias Clasen 2017-04-08 05:10:03 UTC
Review of attachment 342216 [details] [review]:

not sure it helps much, but ok
Comment 18 Ondrej Holy 2017-04-10 08:22:56 UTC
Attachment 342057 [details] pushed as bde2bde - gio-tool: Various memory leak fixes
Attachment 342058 [details] pushed as bcb1bfd - gio-tool: Do not print settable arguments unless they are any
Attachment 342059 [details] pushed as 0946134 - gio-tool: Return error if there are not any volumes to mount
Attachment 342214 [details] pushed as 0beeeb2 - gio-tool: Various fixes related to error messages
Attachment 342215 [details] pushed as 292f10d - gio-tool: Add g_drive_is_removable() support
Attachment 342216 [details] pushed as fb7d218 - gio-tool: Do not leak GOptionContext
Comment 19 Ondrej Holy 2017-06-06 09:14:39 UTC
Created attachment 353245 [details] [review]
gio-tool: Fix alignment of monitor messages

Name of GMount/GVolume/GDrive is aligned in many cases in output messages,
except few cases. Let's unify the alignment.
Comment 20 Philip Withnall 2017-06-06 10:41:19 UTC
Review of attachment 353245 [details] [review]:

++
Comment 21 Ondrej Holy 2017-06-06 11:22:06 UTC
Attachment 353245 [details] pushed as 6863080 - gio-tool: Fix alignment of monitor messages