From e3022229be17e6062a599ef58a43ebde3587d24a Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 12 Oct 2012 16:22:27 +0000 Subject: [PATCH] Bugfix: sizeof(capnames) is not the count, but the size in bytes of the array (so generally 4x the count); use GBT_CAPABILITY_COUNT --- blktemplate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blktemplate.c b/blktemplate.c index 36ad0f0..1de629d 100644 --- a/blktemplate.c +++ b/blktemplate.c @@ -36,14 +36,14 @@ static const char *capnames[] = { }; const char *blktmpl_capabilityname(gbt_capabilities_t caps) { - for (int i = 0; i < sizeof(capnames); ++i) + for (int i = 0; i < GBT_CAPABILITY_COUNT; ++i) if (caps & (1 << i)) return capnames[i]; return NULL; } gbt_capabilities_t blktmpl_getcapability(const char *n) { - for (int i = 0; i < sizeof(capnames); ++i) + for (int i = 0; i < GBT_CAPABILITY_COUNT; ++i) if (capnames[i] && !strcasecmp(n, capnames[i])) return 1 << i; return 0;