@@ -1208,9 +1208,10 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e
12081208 return -1 ;
12091209 }
12101210
1211- if (pstatistic_entry -> statistic_id == STATISTICS_RESERVED_ID ) {
1212- return -2 ;
1213- }
1211+ if (pstatistic_entry -> statistic_id == STATISTICS_RESERVED_ID )
1212+ /* End of statistics entries, return -1 to stop processing the buffer */
1213+ return -1 ;
1214+
12141215
12151216 unsigned int data_size = pstatistic_entry -> statistic_data_size * SIZE_OF_DWORD ;
12161217 __u8 * pdata = (__u8 * )pstatistic_entry +
@@ -1241,23 +1242,31 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e
12411242 json_add_formatted_u32_str (pstatistics_object , STR_RESERVED ,
12421243 pstatistic_entry -> reserved );
12431244 if (pstatistic_entry -> statistic_id == MAX_DIE_BAD_BLOCK_ID ) {
1244- json_add_formatted_u32_str (pstatistics_object , STR_STATISTICS_WORST_DIE_PERCENT ,
1245+ json_add_formatted_u32_str (pstatistics_object ,
1246+ STR_STATISTICS_WORST_DIE_PERCENT ,
12451247 pdata [0 ]);
1246- json_add_formatted_u32_str (pstatistics_object , STR_STATISTICS_WORST_DIE_RAW ,
1248+ json_add_formatted_u32_str (pstatistics_object ,
1249+ STR_STATISTICS_WORST_DIE_RAW ,
12471250 * (__u16 * )& pdata [2 ]);
12481251 } else if (pstatistic_entry -> statistic_id == MAX_NAND_CHANNEL_BAD_BLOCK_ID ) {
1249- json_add_formatted_u32_str (pstatistics_object , STR_STATISTICS_WORST_NAND_CHANNEL_PERCENT ,
1252+ json_add_formatted_u32_str (pstatistics_object ,
1253+ STR_STATISTICS_WORST_NAND_CHANNEL_PERCENT ,
12501254 pdata [0 ]);
1251- json_add_formatted_u32_str (pstatistics_object , STR_STATISTICS_WORST_NAND_CHANNEL_RAW ,
1255+ json_add_formatted_u32_str (pstatistics_object ,
1256+ STR_STATISTICS_WORST_NAND_CHANNEL_RAW ,
12521257 * (__u16 * )& pdata [2 ]);
12531258 } else if (pstatistic_entry -> statistic_id == MIN_NAND_CHANNEL_BAD_BLOCK_ID ) {
1254- json_add_formatted_u32_str (pstatistics_object , STR_STATISTICS_BEST_NAND_CHANNEL_PERCENT ,
1259+ json_add_formatted_u32_str (pstatistics_object ,
1260+ STR_STATISTICS_BEST_NAND_CHANNEL_PERCENT ,
12551261 pdata [0 ]);
1256- json_add_formatted_u32_str (pstatistics_object , STR_STATISTICS_BEST_NAND_CHANNEL_RAW ,
1262+ json_add_formatted_u32_str (pstatistics_object ,
1263+ STR_STATISTICS_BEST_NAND_CHANNEL_RAW ,
12571264 * (__u16 * )& pdata [2 ]);
12581265 } else {
1259- json_add_formatted_var_size_str (pstatistics_object , STR_STATISTICS_SPECIFIC_DATA ,
1260- pdata , data_size );
1266+ json_add_formatted_var_size_str (pstatistics_object ,
1267+ STR_STATISTICS_SPECIFIC_DATA ,
1268+ pdata ,
1269+ data_size );
12611270 }
12621271
12631272 if (pstatistics_object != NULL )
@@ -1283,19 +1292,27 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e
12831292 pdata [0 ]);
12841293 fprintf (fp , "%s: 0x%04x\n" , STR_STATISTICS_WORST_DIE_RAW ,
12851294 * (__u16 * )& pdata [2 ]);
1286- } else if (pstatistic_entry -> statistic_id == MAX_NAND_CHANNEL_BAD_BLOCK_ID ) {
1287- fprintf (fp , "%s: 0x%02x\n" , STR_STATISTICS_WORST_NAND_CHANNEL_PERCENT ,
1295+ } else if (pstatistic_entry -> statistic_id ==
1296+ MAX_NAND_CHANNEL_BAD_BLOCK_ID ) {
1297+ fprintf (fp , "%s: 0x%02x\n" ,
1298+ STR_STATISTICS_WORST_NAND_CHANNEL_PERCENT ,
12881299 pdata [0 ]);
1289- fprintf (fp , "%s: 0x%04x\n" , STR_STATISTICS_WORST_NAND_CHANNEL_RAW ,
1300+ fprintf (fp , "%s: 0x%04x\n" ,
1301+ STR_STATISTICS_WORST_NAND_CHANNEL_RAW ,
12901302 * (__u16 * )& pdata [2 ]);
1291- } else if (pstatistic_entry -> statistic_id == MIN_NAND_CHANNEL_BAD_BLOCK_ID ) {
1292- fprintf (fp , "%s: 0x%02x\n" , STR_STATISTICS_BEST_NAND_CHANNEL_PERCENT ,
1303+ } else if (pstatistic_entry -> statistic_id ==
1304+ MIN_NAND_CHANNEL_BAD_BLOCK_ID ) {
1305+ fprintf (fp , "%s: 0x%02x\n" ,
1306+ STR_STATISTICS_BEST_NAND_CHANNEL_PERCENT ,
12931307 pdata [0 ]);
1294- fprintf (fp , "%s: 0x%04x\n" , STR_STATISTICS_BEST_NAND_CHANNEL_RAW ,
1308+ fprintf (fp , "%s: 0x%04x\n" ,
1309+ STR_STATISTICS_BEST_NAND_CHANNEL_RAW ,
12951310 * (__u16 * )& pdata [2 ]);
12961311 } else {
1297- print_formatted_var_size_str (STR_STATISTICS_SPECIFIC_DATA , pdata ,
1298- data_size , fp );
1312+ print_formatted_var_size_str (STR_STATISTICS_SPECIFIC_DATA ,
1313+ pdata ,
1314+ data_size ,
1315+ fp );
12991316 }
13001317 fprintf (fp , STR_LINE2 );
13011318 } else {
@@ -1318,19 +1335,27 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e
13181335 pdata [0 ]);
13191336 printf ("%s: 0x%04x\n" , STR_STATISTICS_WORST_DIE_RAW ,
13201337 * (__u16 * )& pdata [2 ]);
1321- } else if (pstatistic_entry -> statistic_id == MAX_NAND_CHANNEL_BAD_BLOCK_ID ) {
1322- printf ("%s: 0x%02x\n" , STR_STATISTICS_WORST_NAND_CHANNEL_PERCENT ,
1338+ } else if (pstatistic_entry -> statistic_id ==
1339+ MAX_NAND_CHANNEL_BAD_BLOCK_ID ) {
1340+ printf ("%s: 0x%02x\n" ,
1341+ STR_STATISTICS_WORST_NAND_CHANNEL_PERCENT ,
13231342 pdata [0 ]);
1324- printf ("%s: 0x%04x\n" , STR_STATISTICS_WORST_NAND_CHANNEL_RAW ,
1343+ printf ("%s: 0x%04x\n" ,
1344+ STR_STATISTICS_WORST_NAND_CHANNEL_RAW ,
13251345 * (__u16 * )& pdata [2 ]);
1326- } else if (pstatistic_entry -> statistic_id == MIN_NAND_CHANNEL_BAD_BLOCK_ID ) {
1327- printf ("%s: 0x%02x\n" , STR_STATISTICS_BEST_NAND_CHANNEL_PERCENT ,
1346+ } else if (pstatistic_entry -> statistic_id ==
1347+ MIN_NAND_CHANNEL_BAD_BLOCK_ID ) {
1348+ printf ("%s: 0x%02x\n" ,
1349+ STR_STATISTICS_BEST_NAND_CHANNEL_PERCENT ,
13281350 pdata [0 ]);
1329- printf ("%s: 0x%04x\n" , STR_STATISTICS_BEST_NAND_CHANNEL_RAW ,
1351+ printf ("%s: 0x%04x\n" ,
1352+ STR_STATISTICS_BEST_NAND_CHANNEL_RAW ,
13301353 * (__u16 * )& pdata [2 ]);
13311354 } else {
1332- print_formatted_var_size_str (STR_STATISTICS_SPECIFIC_DATA , pdata ,
1333- data_size , fp );
1355+ print_formatted_var_size_str (STR_STATISTICS_SPECIFIC_DATA ,
1356+ pdata ,
1357+ data_size ,
1358+ fp );
13341359 }
13351360 printf (STR_LINE2 );
13361361 }
0 commit comments