[PATCH v7 4/8] ntdll: Return BIOS info from NtQuerySystemInformation on Linux

Alex Henrie alexhenrie24 at gmail.com
Mon Jun 18 06:32:14 CDT 2018


On Mon, Jun 18, 2018 at 5:26 AM Huw Davies <huw at codeweavers.com> wrote:
>
> On Mon, Jun 18, 2018 at 12:21:52PM +0100, Huw Davies wrote:
> > On Mon, Jun 18, 2018 at 05:09:32AM -0600, Alex Henrie wrote:
> > > Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
> > > ---
> > >  dlls/ntdll/nt.c         | 172 ++++++++++++++++++++++++++++++++++++++++
> > >  dlls/ntdll/tests/info.c |  11 ++-
> > >  2 files changed, 181 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
> > > index dc0ce04f42..40e36c0ffd 100644
> > > --- a/dlls/ntdll/nt.c
> > > +++ b/dlls/ntdll/nt.c
> > > @@ -1850,6 +1879,127 @@ static NTSTATUS create_logical_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION **
> > >  }
> > >  #endif
> > >
> > > +static inline void copy_smbios_string(char **buffer, char *s, size_t len)
> > > +{
> > > +    if (!len) return;
> > > +    strcpy(*buffer, s);
> > > +    *buffer += len + 1;
> > > +}
> > > +
> > > +#ifdef linux
> > > +
> > > +#define FWSS 128 /* firmware string size */
> > > +
> > > +static void get_smbios_string(const char *path, char *s, size_t *len)
> > > +{
> > > +    FILE *file = fopen(path, "r");
> > > +    if (!file)
> > > +    {
> > > +        *len = 0;
> > > +        return;
> > > +    }
> > > +
> > > +    *len = fread(s, 1, FWSS - 1, file);
> >
> > That's pretty ugly.  This function really shouldn't
> > assume the size of the buffer is has to play with.

We're talking about Linux-specific code, and FWSS is used in both
get_smbios_string and get_firmware_info, so it's not much of an
assumption.

> Note, it may be more convenient to use a separate
> 'size' [in] parameter rather than use len as [in,out].

The helper function doesn't need to support more than one buffer size,
so passing the buffer size is redundant.

I'd want to hear at least one more Wine developer's opinion before
making a change.

-Alex



More information about the wine-devel mailing list