[PATCH 1/3] util: Introduce virAcpi module

Jiri Denemark jdenemar at redhat.com
Wed Apr 12 10:37:39 UTC 2023


On Thu, Apr 06, 2023 at 02:20:31 -0700, Andrea Bolognani wrote:
> On Thu, Apr 06, 2023 at 10:20:46AM +0200, Michal Prívozník wrote:
> > On 4/5/23 19:21, Andrea Bolognani wrote:
> > > On Wed, Apr 05, 2023 at 01:30:17PM +0200, Michal Privoznik wrote:
> > >> +    if (nodeHeader->len < sizeof(*nodeHeader)) {
> > >> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> > >> +                       _("IORT table node type %1$s has invalid length: %2$" PRIu16),
> > >
> > > I'm not sure this plays well with the recently introduced changes to
> > > translatable strings. Have you checked with Jirka?
> >
> > I haven't. But, gcc complains if only a part of string contains
> > positioned arguments. That is:
> >
> >   "argument value %1$s and another argument %s"
> >   "argument value %s and another argument %2$s"
> >
> > are invalid format string and compiler throws an error. Now, using no
> > positions works:
> >
> >   "argument value %s and another argument %s"
> >
> > but then, Jirka's syntax-check rule throws an error. But it doesn't for
> > the case I'm using:
> >
> >   "integer value %" PRIu16
> 
> Yeah, either your usage is fine or the syntax-check rule should be
> improve to catch it. Jirka?

Yeah, the syntax check is quite simple so it doesn't catch all possible
cases and libvirt-pot-check run after libvirt-pot (either in our CI or
manually) will detect all cases.

> > Although, one could argue that if the translate tool doesn't allow fixed
> > size integer types modifiers, then the tool is broken. Surely, libvirt's
> > not the only one using fixed size integers. But okay, for error messages

Well, not really. The tool is not a C preprocessor so it doesn't have
any idea what a specific macro you concatenate with an actual string is.
So the best thing to do here is to avoid the situation and do what you
came up with here:

> > I can typecast arguments. IOW:
> >
> >  virReportError(VIR_ERR_INTERNAL_ERROR,
> >                 _("IORT table node type %1$s has invalid length: %2$u"),
> >                 NULLSTR(typeStr), (unsigned int)nodeHeader->len);

Jirka


More information about the libvir-list mailing list