X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=common.c;h=7d52530e59873db82626d18ea5793b5d950529c0;hb=b0eb18cc89c5d16d2a47d64994bef03b52d087e7;hp=5b938dd5b26570b9731526f74e266a412a2a4519;hpb=a85769a88b81f22aa43895199cbb01a12e0ab0a7;p=pciutils.git diff --git a/common.c b/common.c index 5b938dd..7d52530 100644 --- a/common.c +++ b/common.c @@ -1,7 +1,7 @@ /* - * Linux PCI Utilities -- Common Functions + * The PCI Utilities -- Common Functions * - * Copyright (c) 1997--1999 Martin Mares + * Copyright (c) 1997--2006 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -14,13 +14,13 @@ #include "pciutils.h" -void __attribute__((noreturn)) +void NONRET die(char *msg, ...) { va_list args; va_start(args, msg); - fputs("lspci: ", stderr); + fprintf(stderr, "%s: ", program_name); vfprintf(stderr, msg, args); fputc('\n', stderr); exit(1); @@ -35,18 +35,27 @@ xmalloc(unsigned int howmuch) return p; } +void * +xrealloc(void *ptr, unsigned int howmuch) +{ + void *p = realloc(ptr, howmuch); + if (!p) + die("Unable to allocate %d bytes of memory", howmuch); + return p; +} + int parse_generic_option(int i, struct pci_access *pacc, char *optarg) { switch (i) { -#ifdef HAVE_PM_LINUX_PROC +#ifdef PCI_HAVE_PM_LINUX_PROC case 'P': pacc->method_params[PCI_ACCESS_PROC_BUS_PCI] = optarg; pacc->method = PCI_ACCESS_PROC_BUS_PCI; break; #endif -#ifdef HAVE_PM_INTEL_CONF +#ifdef PCI_HAVE_PM_INTEL_CONF case 'H': if (!strcmp(optarg, "1")) pacc->method = PCI_ACCESS_I386_TYPE1; @@ -56,12 +65,7 @@ parse_generic_option(int i, struct pci_access *pacc, char *optarg) die("Unknown hardware configuration type %s", optarg); break; #endif -#ifdef HAVE_PM_SYSCALLS - case 'S': - pacc->method = PCI_ACCESS_SYSCALLS; - break; -#endif -#ifdef HAVE_PM_DUMP +#ifdef PCI_HAVE_PM_DUMP case 'F': pacc->method_params[PCI_ACCESS_DUMP] = optarg; pacc->method = PCI_ACCESS_DUMP;