Re: [libvirt] [PATCH] fix diagnostic when execute openvz commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Evgeniy Sokolov <evg@xxxxxxxxxx> wrote:
>> This really needs to be changed to pass through gettext, eg
>>
>>    error(dom->conn, VIR_ERR_INTERNAL_ERROR,
>>          _("Could not exec %s"), VZCTL);
>>
>> NB, we have to use a %s format string when going via gettext rather than
>> just allowing the preprocessor to do string concatenation for us.
>
> Ok, it need. Thanks!
>
> Index: openvz_conf.c
> ===================================================================
...
> -/* For errors internal to this library. */
> -static void
> -error (virConnectPtr conn, virErrorNumber code, const char *info)
> +void
> +error (virConnectPtr conn, virErrorNumber code, const char *fmt, ...)

Now that you've given it external scope, please use a different name.
There are already at least two other "error" functions,
including the static one in remote_internal.c, and the
external one in glibc/gnulib.

...
> Index: openvz_conf.h
> ===================================================================
> RCS file: /data/cvs/libvirt/src/openvz_conf.h,v
> retrieving revision 1.6
> diff -u -p -r1.6 openvz_conf.h
> --- openvz_conf.h	5 Feb 2008 19:27:37 -0000	1.6
> +++ openvz_conf.h	9 Jul 2008 10:08:49 -0000
> @@ -110,6 +110,7 @@ openvzIsActiveVM(struct openvz_vm *vm)
>      return vm->vpsid != -1;
>  }
>
> +void error (virConnectPtr conn, virErrorNumber code, const char *fmt, ...);

Whatever its name, please do two more things:

  - add "ATTRIBUTE_FORMAT(printf, 3, 4)" before the semicolon, so that
  gcc -Wformat compares the format string with types of corresponding arguments.
  (this must be done with any varargs "..." printf/scanf-style function)

  - add the new name to the list in Makefile.cfg (msg_gen_function),
  and ensure that "make syntax-check" passes.
  (this must be done for any function that takes a diagnostic
   string as an argument)

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]