EX-8311 patch modifies compr_type_table to contain NULL fields in the
array, so iterate over the array should not use ARRAY_SIZE, but skip
those elements with NULL compression type name.
Fixes:
ec5814c9a7 ("EX-8311 csdc: allow specify 'fast'/'best' compression type")
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I8e4988fd3a63c1cb66f75510d190c2ebc4f8f9be
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53808
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
static inline const char *compress_type_2str(__u8 compr_type)
{
bool found = false;
- int i = 0;
+ int i;
- for (i = 0; compr_type_table[i].ctn_name != NULL; i++) {
+ for (i = LL_COMPR_TYPE_NONE; i < LL_COMPR_TYPE_MAX; i++) {
+ if (compr_type_table[i].ctn_name == NULL)
+ continue;
if (compr_type == compr_type_table[i].ctn_compr_type) {
found = true;
break;
int i;
bool known_type = false;
- for (i = 0; compr_type_table[i].ctn_name != NULL; i++) {
+ for (i = LL_COMPR_TYPE_NONE; i < LL_COMPR_TYPE_MAX; i++) {
+ if (compr_type_table[i].ctn_name == NULL)
+ continue;
if (compr_type_table[i].ctn_compr_type == type) {
known_type = true;
if (compr_type_table[i].ctn_to_compr_level != NULL)
int i;
int rc = 0;
- for (i = 0; compr_type_table[i].ctn_name != NULL; i++) {
+ for (i = LL_COMPR_TYPE_NONE; i < LL_COMPR_TYPE_MAX; i++) {
+ if (compr_type_table[i].ctn_name == NULL)
+ continue;
if (strcmp(s_type, compr_type_table[i].ctn_name) == 0) {
*type = compr_type_table[i].ctn_compr_type;
found_type = true;
if (param->fp_check_compr_lvl) {
- for (j = 0; j < ARRAY_SIZE(compr_type_table); j++) {
+ for (j = LL_COMPR_TYPE_NONE;
+ j < LL_COMPR_TYPE_MAX; j++) {
+ if (compr_type_table[j].ctn_name == NULL)
+ continue;
if (compr_type_table[j].ctn_compr_type !=
entry->lcme_compr_type)
continue;
}
if (param->fp_check_compr_chunk) {
- for (j = 0; j < ARRAY_SIZE(compr_type_table); j++) {
+ for (j = LL_COMPR_TYPE_NONE;
+ j < LL_COMPR_TYPE_MAX; j++) {
+ if (compr_type_table[j].ctn_name == NULL)
+ continue;
if (compr_type_table[j].ctn_compr_type !=
entry->lcme_compr_type)
continue;
*sign = '\0';
}
- for (i = 0; i < ARRAY_SIZE(compr_type_table); i++) {
+ for (i = LL_COMPR_TYPE_NONE; i < LL_COMPR_TYPE_MAX; i++) {
+ if (compr_type_table[i].ctn_name == NULL)
+ continue;
if (strcmp(argbuf, compr_type_table[i].ctn_name) == 0) {
*type = compr_type_table[i].ctn_compr_type;
found = true;
printed = true;
}
- for (i = 0; i < ARRAY_SIZE(compr_type_table); i++) {
+ for (i = LL_COMPR_TYPE_NONE; i < LL_COMPR_TYPE_MAX; i++) {
+ if (compr_type_table[i].ctn_name == NULL)
+ continue;
if (compr_type_table[i].ctn_compr_type == type) {
if (compr_type_table[i].ctn_from_compr_level != NULL) {
comp->llc_compr_lvl = compr_type_table[i].