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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user