mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-10-23 15:13:09 +00:00
Use ARRAYLEN when possible
This commit is contained in:
4 files changed
+6
-10
No files matched your search
@@ -121,10 +121,6 @@ extern uint8_t spi_flash_pages64k;
|
||||
|
||||
bool FlashDetect(void);
|
||||
|
||||
#ifndef ARRAYLEN
|
||||
# define ARRAYLEN(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#endif // #ifndef AS_BOOTROM
|
||||
|
||||
#endif // FLASHMEM_H_
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "commonutil.h"
|
||||
#include "fpga_gw_jtag.h"
|
||||
|
||||
#define INST_BYPASS 0xFF
|
||||
@@ -105,12 +106,9 @@ static const device_map_t device_map[] = {
|
||||
// #define ID_GW1NS_2C 0x0300181B
|
||||
};
|
||||
|
||||
// 计算当前设备映射表中的设备型号数量
|
||||
#define DEVICE_SIZE (sizeof(device_map) / sizeof(device_map[0]))
|
||||
|
||||
// 根据ID索引到具体的设备信息映射表上,如果没有发现对应的设备存在,则返回NULL
|
||||
static const device_map_t *get_device_map_by_idcode(void) {
|
||||
for (size_t i = 0; i < DEVICE_SIZE; i++) {
|
||||
for (size_t i = 0; i < ARRAYLEN(device_map); i++) {
|
||||
if (device_map[i].idcode == cached_idcode) {
|
||||
return &device_map[i];
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define GPIO_HW_AT32_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "commonutil.h"
|
||||
#include "config_gpio.h"
|
||||
|
||||
|
||||
@@ -11,7 +12,7 @@
|
||||
#define AT32_GPIO_PERIPH_CLKS_ENABLE(...) \
|
||||
do { \
|
||||
const crm_periph_clock_type args[] = { __VA_ARGS__ }; \
|
||||
for (size_t i = 0; i < sizeof(args) / sizeof(args[0]); ++i) { \
|
||||
for (size_t i = 0; i < ARRAYLEN(args); ++i) { \
|
||||
crm_periph_clock_enable(args[i], TRUE); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Created by dxl on 2026/5/23.
|
||||
//
|
||||
|
||||
#include "commonutil.h"
|
||||
#include "sys_apis.h"
|
||||
#include "config_gpio_proxmark5.h"
|
||||
|
||||
@@ -419,7 +420,7 @@ void system_simple_reset(void) {
|
||||
void __NO_RETURN JumpToAnyImage(uint32_t stack_top, uint32_t entry_point) {
|
||||
// Disable and clear all pending interrupts in the Bootloader
|
||||
__disable_irq();
|
||||
for (int i = 0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]); i++) {
|
||||
for (int i = 0; i < ARRAYLEN(NVIC->ICER); i++) {
|
||||
NVIC->ICER[i] = 0xFFFFFFFF;
|
||||
NVIC->ICPR[i] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user