From 1ac3a99ddd2970eab0238d3aae190d393c565839 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 6 Feb 2007 13:02:08 +0100 Subject: [PATCH] Get rid of bzero(). --- ChangeLog | 3 +++ lib/access.c | 4 ++-- lib/aix-device.c | 2 +- lib/generic.c | 4 ++-- lib/names.c | 2 +- lib/sysdep.h | 1 - lspci.c | 6 +++--- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ebadcf..5d82f18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2007-02-06 Martin Mares + * Replaced bzero() by memset() everywhere, it's better to lose a tiny + bit of readability than maintain hacks to make it work on various systems. + * lib/configure: tr on Solaris is a bit weird and it requires `[A-Z]' instead of `A-Z'. Fortunately, the extra brackets don't hurt otherwise. diff --git a/lib/access.c b/lib/access.c index 7e3fb71..d4999d6 100644 --- a/lib/access.c +++ b/lib/access.c @@ -65,7 +65,7 @@ pci_alloc(void) struct pci_access *a = malloc(sizeof(struct pci_access)); int i; - bzero(a, sizeof(*a)); + memset(a, 0, sizeof(*a)); pci_set_name_list_path(a, PCI_PATH_IDS_DIR "/" PCI_IDS, 0); for(i=0; iconfig) @@ -197,7 +197,7 @@ pci_alloc_dev(struct pci_access *a) { struct pci_dev *d = pci_malloc(a, sizeof(struct pci_dev)); - bzero(d, sizeof(*d)); + memset(d, 0, sizeof(*d)); d->access = a; d->methods = a->methods; d->hdrtype = -1; diff --git a/lib/aix-device.c b/lib/aix-device.c index 2c6a2cc..e02c98d 100644 --- a/lib/aix-device.c +++ b/lib/aix-device.c @@ -207,7 +207,7 @@ aix_scan(struct pci_access *a) int bus_number; byte busmap[256]; - bzero(busmap, sizeof(busmap)); + memset(busmap, 0, sizeof(busmap)); for (i = 0; i < pci_bus_count; i++) { bus_number = pci_buses[i].bus_number; diff --git a/lib/generic.c b/lib/generic.c index b1b1c8e..617c5fe 100644 --- a/lib/generic.c +++ b/lib/generic.c @@ -70,7 +70,7 @@ pci_generic_scan(struct pci_access *a) { byte busmap[256]; - bzero(busmap, sizeof(busmap)); + memset(busmap, 0, sizeof(busmap)); pci_generic_scan_bus(a, busmap, 0); } @@ -93,7 +93,7 @@ pci_generic_fill_info(struct pci_dev *d, int flags) if (flags & PCI_FILL_BASES) { int cnt = 0, i; - bzero(d->base_addr, sizeof(d->base_addr)); + memset(d->base_addr, 0, sizeof(d->base_addr)); switch (d->hdrtype) { case PCI_HEADER_TYPE_NORMAL: diff --git a/lib/names.c b/lib/names.c index c1b3081..6d671d1 100644 --- a/lib/names.c +++ b/lib/names.c @@ -326,7 +326,7 @@ pci_load_name_list(struct pci_access *a) if (!(f = pci_open(a))) return 0; a->id_hash = pci_malloc(a, sizeof(struct id_entry *) * HASH_SIZE); - bzero(a->id_hash, sizeof(struct id_entry *) * HASH_SIZE); + memset(a->id_hash, 0, sizeof(struct id_entry *) * HASH_SIZE); err = id_parse_list(a, f, &lino); PCI_ERROR(f, err); pci_close(f); diff --git a/lib/sysdep.h b/lib/sysdep.h index a54222f..2a25c93 100644 --- a/lib/sysdep.h +++ b/lib/sysdep.h @@ -19,7 +19,6 @@ typedef u8 byte; typedef u16 word; #ifdef PCI_OS_WINDOWS -#define bzero(x,y) memset(x,0,y) #define strcasecmp strcmpi #endif diff --git a/lspci.c b/lspci.c index 9c6a0c2..5c12383 100644 --- a/lspci.c +++ b/lspci.c @@ -99,7 +99,7 @@ config_fetch(struct device *d, unsigned int pos, unsigned int len) d->config_bufsize *= 2; d->config = xrealloc(d->config, d->config_bufsize); d->present = xrealloc(d->present, d->config_bufsize); - bzero(d->present + orig_size, d->config_bufsize - orig_size); + memset(d->present + orig_size, 0, d->config_bufsize - orig_size); } result = pci_read_block(d->dev, pos, d->config + pos, len); if (result) @@ -117,7 +117,7 @@ scan_device(struct pci_dev *p) if (!pci_filter_match(&filter, p)) return NULL; d = xmalloc(sizeof(struct device)); - bzero(d, sizeof(*d)); + memset(d, 0, sizeof(*d)); d->dev = p; d->config_cached = d->config_bufsize = 64; d->config = xmalloc(64); @@ -2316,7 +2316,7 @@ map_the_bus(void) pacc->method == PCI_ACCESS_DUMP) printf("WARNING: Bus mapping can be reliable only with direct hardware access enabled.\n\n"); bus_info = xmalloc(sizeof(struct bus_info) * 256); - bzero(bus_info, sizeof(struct bus_info) * 256); + memset(bus_info, 0, sizeof(struct bus_info) * 256); if (filter.bus >= 0) do_map_bus(filter.bus); else -- 2.39.2