[Libguestfs] [PATCH 2/2] Use 'error' function for fprintf followed by exit.

Richard W.M. Jones rjones at redhat.com
Mon Apr 4 14:37:42 UTC 2016


On Mon, Apr 04, 2016 at 03:06:52PM +0200, Pino Toscano wrote:
> What about
> 
>   error (EXIT_FAILURE, errno, _("failed to create handle"));
> 
> instead?

If you have:

  error (EXIT_FAILURE, errno, "guestfs_create");

then:

 - guestfs_create isn't translated (it shouldn't be, because it's an API)

 - the error message is translated

So I believe in the French locale you'd see something like:

  guestfs_create: fichier non trouvé

Whereas the way you suggested would show:

  impossible de créer l'identificateur: fichier non trouvé

Imagine that's a language that you can't read.  It's a matter of
style, but I think the first one makes it a bit easier for developers
to work out what's going on.

It's also consistent with our other uses, eg. error (EXIT_FAILURE, errno,
"malloc").

> Also for all the occurrences of this change, in public tools
> only (i.e. not for tests, nor p2v).

Do you mean because of use of gettext?

> Something I noticed while reading the changes is that some of the error
> messages end with period, while it seems most of them don't.  Should
> all of them be without?

It would be nice to fix this globally and only once with some kind of
checkpatch script, which is something I'm looking into at the moment.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list