Bugfix: sizeof(capnames) is not the count, but the size in bytes of the array (so generally 4x the count); use GBT_CAPABILITY_COUNT

This commit is contained in:
Luke Dashjr
2012-10-12 16:22:27 +00:00
parent 75656b568c
commit e3022229be

View File

@@ -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;