From fdd20b52391b9d491b37fb7d3e157ea5db098062 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Tue, 13 Apr 2010 00:34:20 +0200 Subject: [PATCH] Add ARRAY_SIZE helper. --- hardware/zeroplus-logic-cube/zeroplus.c | 2 +- sigrok.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 4a1e46fc..e5b05ac6 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -156,7 +156,7 @@ struct sigrok_device_instance *zp_open_device(int device_index) if(des.idVendor == USB_VENDOR) { if(libusb_get_bus_number(devlist[i]) == sdi->usb->bus && libusb_get_device_address(devlist[i]) == sdi->usb->address) { - for (j = 0; j < sizeof(zeroplus_models) / sizeof(zeroplus_models[0]); j++) { + for (j = 0; j < ARRAY_SIZE(zeroplus_models); j++) { if (des.idProduct == zeroplus_models[j].pid) { g_message("Found PID=%04X (%s)", des.idProduct, zeroplus_models[j].model_name); num_channels = zeroplus_models[j].channels; diff --git a/sigrok.h b/sigrok.h index 1eedd8bc..4b6e2640 100644 --- a/sigrok.h +++ b/sigrok.h @@ -54,6 +54,10 @@ #define MHZ(n) (n * 1000000) #define GHZ(n) (n * 1000000000) +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif + /* Data types, used by hardware plugins for set_configuration() */ enum { T_UINT64,