Re: [PATCH 4/7] Add a sysinfo util module and read host info API

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

 



On Tue, Nov 02, 2010 at 05:36:46PM +0100, Daniel Veillard wrote:
> +virSysinfoDefPtr
> +virSysinfoRead(void) {
> +    char *path, *cur, *eol, *base;
> +    int pid, outfd = -1, errfd = -1;
> +    virSysinfoDefPtr ret = NULL;
> +    const char **argv;
> +    int n, res, waitret, exitstatus;
> +    char *outbuf = NULL;
> +    char *errbuf = NULL;
> +
> +    path = virFindFileInPath(SYSINFO_SMBIOS_DECODER);
> +    if (path == NULL) {
> +        virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
> +                           _("Failed to find path for %s binary"),
> +                             SYSINFO_SMBIOS_DECODER);
> +        return(NULL);
> +    }
> +
> +    n = 1 + /* dmidecode */
> +        1 + /* -q */
> +        2;  /* -t 0,1 */
> +
> +    if (VIR_ALLOC_N(argv, n + 1) < 0)
> +        return(NULL);
> +
> +    n = 0;
> +    argv[n++] = path;
> +    argv[n++] = "-q";
> +    argv[n++] = "-t";
> +    argv[n++] = "0,1";
> +    argv[n] = NULL;

Since there's no conditionally included args here, it is simpler
to avoid the counting of args & alloc & just pre-declare argv

  const char *argv[] = { path, "-q", "-t", "0,1", NULL };


Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]