[FL-2811] Fix PVS-Studio warnings (#2142)
Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
@@ -73,24 +73,14 @@ bool all_in_one_parser_parse(NfcDeviceData* dev_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the layout is a then the ride count is stored in the first byte of page 8
|
||||
uint8_t ride_count = 0;
|
||||
uint32_t serial = 0;
|
||||
if(all_in_one_get_layout(dev_data) == ALL_IN_ONE_LAYOUT_A) {
|
||||
// If the layout is A then the ride count is stored in the first byte of page 8
|
||||
ride_count = dev_data->mf_ul_data.data[4 * 8];
|
||||
} else if(all_in_one_get_layout(dev_data) == ALL_IN_ONE_LAYOUT_D) {
|
||||
// If the layout is D, the ride count is stored in the second byte of page 9
|
||||
ride_count = dev_data->mf_ul_data.data[4 * 9 + 1];
|
||||
// I hate this with a burning passion.
|
||||
|
||||
// The number starts at the second half of the third byte on page 4, and is 32 bits long
|
||||
// So we get the second half of the third byte, then bytes 4-6, and then the first half of the 7th byte
|
||||
// B8 17 A2 A4 BD becomes 81 7A 2A 4B
|
||||
serial = (dev_data->mf_ul_data.data[4 * 4 + 2] & 0x0F) << 28 |
|
||||
dev_data->mf_ul_data.data[4 * 4 + 3] << 20 |
|
||||
dev_data->mf_ul_data.data[4 * 4 + 4] << 12 |
|
||||
dev_data->mf_ul_data.data[4 * 4 + 5] << 4 |
|
||||
(dev_data->mf_ul_data.data[4 * 4 + 6] >> 4);
|
||||
} else {
|
||||
FURI_LOG_I("all_in_one", "Unknown layout: %d", all_in_one_get_layout(dev_data));
|
||||
ride_count = 137;
|
||||
@@ -110,4 +100,4 @@ bool all_in_one_parser_parse(NfcDeviceData* dev_data) {
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data, "\e#All-In-One\nNumber: %lu\nRides left: %u", serial, ride_count);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -116,26 +116,9 @@ bool plantain_4k_parser_parse(NfcDeviceData* dev_data) {
|
||||
for(size_t i = 0; i < 7; i++) {
|
||||
card_number = (card_number << 8) | card_number_arr[i];
|
||||
}
|
||||
// Convert card number to string
|
||||
FuriString* card_number_str;
|
||||
card_number_str = furi_string_alloc();
|
||||
// Should look like "361301047292848684"
|
||||
furi_string_printf(card_number_str, "%llu", card_number);
|
||||
// Add suffix with luhn checksum (1 digit) to the card number string
|
||||
FuriString* card_number_suffix;
|
||||
card_number_suffix = furi_string_alloc();
|
||||
|
||||
furi_string_cat_printf(card_number_suffix, "-");
|
||||
furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix));
|
||||
// Free all not needed strings
|
||||
furi_string_free(card_number_suffix);
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data,
|
||||
"\e#Plantain\nN:%s\nBalance:%ld\n",
|
||||
furi_string_get_cstr(card_number_str),
|
||||
balance);
|
||||
furi_string_free(card_number_str);
|
||||
dev_data->parsed_data, "\e#Plantain\nN:%llu-\nBalance:%ld\n", card_number, balance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -89,26 +89,9 @@ bool plantain_parser_parse(NfcDeviceData* dev_data) {
|
||||
for(size_t i = 0; i < 7; i++) {
|
||||
card_number = (card_number << 8) | card_number_arr[i];
|
||||
}
|
||||
// Convert card number to string
|
||||
FuriString* card_number_str;
|
||||
card_number_str = furi_string_alloc();
|
||||
// Should look like "361301047292848684"
|
||||
furi_string_printf(card_number_str, "%llu", card_number);
|
||||
// Add suffix with luhn checksum (1 digit) to the card number string
|
||||
FuriString* card_number_suffix;
|
||||
card_number_suffix = furi_string_alloc();
|
||||
|
||||
furi_string_cat_printf(card_number_suffix, "-");
|
||||
furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix));
|
||||
// Free all not needed strings
|
||||
furi_string_free(card_number_suffix);
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data,
|
||||
"\e#Plantain\nN:%s\nBalance:%ld\n",
|
||||
furi_string_get_cstr(card_number_str),
|
||||
balance);
|
||||
furi_string_free(card_number_str);
|
||||
dev_data->parsed_data, "\e#Plantain\nN:%llu-\nBalance:%ld\n", card_number, balance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -117,19 +117,6 @@ bool two_cities_parser_parse(NfcDeviceData* dev_data) {
|
||||
for(size_t i = 0; i < 7; i++) {
|
||||
card_number = (card_number << 8) | card_number_arr[i];
|
||||
}
|
||||
// Convert card number to string
|
||||
FuriString* card_number_str;
|
||||
card_number_str = furi_string_alloc();
|
||||
// Should look like "361301047292848684"
|
||||
furi_string_printf(card_number_str, "%llu", card_number);
|
||||
// Add suffix with luhn checksum (1 digit) to the card number string
|
||||
FuriString* card_number_suffix;
|
||||
card_number_suffix = furi_string_alloc();
|
||||
|
||||
furi_string_cat_printf(card_number_suffix, "-");
|
||||
furi_string_cat_printf(card_number_str, furi_string_get_cstr(card_number_suffix));
|
||||
// Free all not needed strings
|
||||
furi_string_free(card_number_suffix);
|
||||
|
||||
// =====
|
||||
// --PLANTAIN--
|
||||
@@ -149,12 +136,11 @@ bool two_cities_parser_parse(NfcDeviceData* dev_data) {
|
||||
|
||||
furi_string_printf(
|
||||
dev_data->parsed_data,
|
||||
"\e#Troika+Plantain\nPN: %s\nPB: %ld rur.\nTN: %ld\nTB: %d rur.\n",
|
||||
furi_string_get_cstr(card_number_str),
|
||||
"\e#Troika+Plantain\nPN: %llu-\nPB: %ld rur.\nTN: %ld\nTB: %d rur.\n",
|
||||
card_number,
|
||||
balance,
|
||||
troika_number,
|
||||
troika_balance);
|
||||
furi_string_free(card_number_str);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user