Skip to content

Commit b972dd8

Browse files
committed
Use case sensitivity in regexp everywhere
1 parent f0642d0 commit b972dd8

File tree

20 files changed

+90
-96
lines changed

20 files changed

+90
-96
lines changed

src/chipid.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ char nor_chip[128];
2525
static long get_uart0_address() {
2626
char buf[256];
2727

28-
bool res = get_regex_line_from_file(
29-
"/proc/iomem", "^([0-9a-f]+)-[0-9a-f]+ : .*uart[@:][0-9]", buf,
30-
sizeof(buf));
28+
bool res = line_from_file("/proc/iomem",
29+
"^([0-9a-f]+)-[0-9a-f]+ : .*uart[@:][0-9]", buf,
30+
sizeof(buf));
3131
if (!res) {
3232
return -1;
3333
}
@@ -53,7 +53,7 @@ static const manufacturers_t manufacturers[] = {
5353
{"FH", fh_detect_cpu, "Fullhan", fh_setup_hal},
5454
{NULL /* Generic */, rockchip_detect_cpu, "Rockchip", rockchip_setup_hal},
5555
{"Xilinx", xilinx_detect_cpu, NULL, xilinx_setup_hal},
56-
{"BCM", bcm_detect_cpu, NULL, bcm_setup_hal}
56+
{"BCM", bcm_detect_cpu, "Broadcom", bcm_setup_hal}
5757
#endif
5858
#if defined(__aarch64__) || defined(_M_ARM64)
5959
{NULL, tegra_detect_cpu, "Nvidia", tegra_setup_hal},
@@ -64,11 +64,11 @@ static bool generic_detect_cpu() {
6464
char buf[256] = "unknown";
6565

6666
strcpy(chip_name, "unknown");
67-
bool res = get_regex_line_from_file(
68-
"/proc/cpuinfo", "Hardware\\t+: ([a-zA-Z-]+)", buf, sizeof(buf));
67+
bool res = line_from_file("/proc/cpuinfo", "Hardware\\t+: ([a-zA-Z-]+)",
68+
buf, sizeof(buf));
6969
if (!res) {
70-
res = get_regex_line_from_file("/proc/cpuinfo", "vendor_id\t+: (.+)",
71-
buf, sizeof(buf));
70+
res = line_from_file("/proc/cpuinfo", "vendor_id\t+: (.+)", buf,
71+
sizeof(buf));
7272
}
7373
strcpy(chip_manufacturer, buf);
7474

src/hal/bcm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
bool bcm_detect_cpu(char *chip_name) {
1313
char buf[256];
1414

15-
if (!get_regex_line_from_file("/proc/cpuinfo", "Hardware.+: (BCM[0-9-]+)",
16-
buf, sizeof(buf)))
15+
if (!line_from_file("/proc/cpuinfo", "Hardware.+: (BCM[0-9-]+)", buf,
16+
sizeof(buf)))
1717
return false;
1818

1919
strcpy(chip_name, buf);
@@ -26,7 +26,7 @@ static void cpuinfo_param(cJSON *j_inner, char *name) {
2626
char out[256], pattern[256];
2727

2828
snprintf(pattern, sizeof(pattern), "%s.+: (.+)", name);
29-
if (!get_regex_line_from_file("/proc/cpuinfo", pattern, out, sizeof(out)))
29+
if (!line_from_file("/proc/cpuinfo", pattern, out, sizeof(out)))
3030
return;
3131

3232
lsnprintf(pattern, sizeof(pattern), name);

src/hal/fh.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ bool fh_detect_cpu(char *chip_name) {
2525
uint32_t sysctrl, ipver, reg;
2626
unsigned int chip_id = 0;
2727

28-
if (!get_regex_line_from_file(
29-
"/proc/cpuinfo", "Hardware.+: ([a-zA-Z0-9-]+)", buf, sizeof(buf)))
28+
if (!line_from_file("/proc/cpuinfo", "Hardware.+: ([a-zA-Z0-9-]+)", buf,
29+
sizeof(buf)))
3030
return false;
3131

3232
mem_reg(REG_PMU_SYS_CTRL, (uint32_t *)&sysctrl, OP_READ);
@@ -109,8 +109,8 @@ bool fh_detect_cpu(char *chip_name) {
109109
static unsigned long fh_media_mem() {
110110
char buf[256];
111111

112-
if (!get_regex_line_from_file("/proc/driver/vmm", "total.size=([0-9A-Fx]+)",
113-
buf, sizeof(buf)))
112+
if (!line_from_file("/proc/driver/vmm", "total.size=([0-9A-Fx]+)", buf,
113+
sizeof(buf)))
114114
return 0;
115115
return strtoul(buf, NULL, 10) * 1024;
116116
}
@@ -123,8 +123,8 @@ unsigned long fh_totalmem(unsigned long *media_mem) {
123123
float fh_get_temp() {
124124
float ret = -237.0;
125125
char buf[16];
126-
if (get_regex_line_from_file("/sys/class/thermal/thermal_zone0/temp",
127-
"(.+)", buf, sizeof(buf))) {
126+
if (line_from_file("/sys/class/thermal/thermal_zone0/temp", "(.+)", buf,
127+
sizeof(buf))) {
128128
ret = strtof(buf, NULL);
129129
}
130130
return ret;

src/hal/gm.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ bool gm_detect_cpu(char *chip_name) {
2424
char buf[256];
2525
char chip[256];
2626

27-
if (!get_regex_line_from_file("/proc/pmu/chipver", "([0-9]+)", buf,
28-
sizeof(buf)))
27+
if (!line_from_file("/proc/pmu/chipver", "([0-9]+)", buf, sizeof(buf)))
2928
return false;
3029
sprintf(chip_name, "GM%.4s", buf);
3130
return true;
@@ -34,8 +33,8 @@ bool gm_detect_cpu(char *chip_name) {
3433
static unsigned long gm_media_mem() {
3534
char buf[256];
3635
// Fixme: this seems to be currently allocated size
37-
if (!get_regex_line_from_file("/proc/frammap/ddr_info",
38-
"size:.([0-9A-Fx]+)", buf, sizeof(buf)))
36+
if (!line_from_file("/proc/frammap/ddr_info", "size:.([0-9A-Fx]+)", buf,
37+
sizeof(buf)))
3938
return 0;
4039
return strtoul(buf, NULL, 16) / 1024;
4140
}
@@ -48,8 +47,8 @@ unsigned long gm_totalmem(unsigned long *media_mem) {
4847
float gm_get_temp() {
4948
float ret = -237.0;
5049
char buf[16];
51-
if (get_regex_line_from_file("/sys/class/thermal/thermal_zone0/temp",
52-
"(.+)", buf, sizeof(buf))) {
50+
if (line_from_file("/sys/class/thermal/thermal_zone0/temp", "(.+)", buf,
51+
sizeof(buf))) {
5352
ret = strtof(buf, NULL);
5453
}
5554
return ret;

src/hal/hisi/hal_hisi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,17 +304,17 @@ int sony_ssp_read_register(int fd, unsigned char i2c_addr,
304304
static unsigned long hisi_media_mem() {
305305
char buf[256];
306306

307-
if (!get_regex_line_from_file("/proc/media-mem", "total size=([0-9]+)KB",
308-
buf, sizeof(buf))) {
307+
if (!line_from_file("/proc/media-mem", "total size=([0-9]+)KB", buf,
308+
sizeof(buf))) {
309309
return 0;
310310
}
311311
return strtoul(buf, NULL, 10);
312312
}
313313

314314
static bool is_cma_allocator() {
315315
char buf[64];
316-
if (get_regex_line_from_file("/proc/cmdline", "mmz_allocator=(\\w+)", buf,
317-
sizeof(buf))) {
316+
if (line_from_file("/proc/cmdline", "mmz_allocator=(\\w+)", buf,
317+
sizeof(buf))) {
318318
if (!strcmp(buf, "cma"))
319319
return true;
320320
}
@@ -390,8 +390,8 @@ static void hisi_hal_cleanup() {
390390
static void get_hisi_sdk(cJSON *j_inner) {
391391
char buf[1024];
392392

393-
if (get_regex_line_from_file("/proc/umap/sys", "Version: \\[(.+)\\]", buf,
394-
sizeof(buf))) {
393+
if (line_from_file("/proc/umap/sys", "Version: \\[(.+)\\]", buf,
394+
sizeof(buf))) {
395395
char *ptr = strchr(buf, ']');
396396
char *build = strchr(buf, '[');
397397
if (!ptr || !build)

src/hal/ingenic.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ static unsigned char onsemi_addrs[] = {0x20, 0};
1515
static unsigned char gc_addrs[] = {0x6e, 0x52, 0};
1616
static unsigned char soi_addrs[] = {0x60, 0x80, 0};
1717

18-
sensor_addr_t ingenic_possible_i2c_addrs[] = {
19-
{SENSOR_SONY, sony_addrs}, {SENSOR_SMARTSENS, ssens_addrs},
20-
{SENSOR_ONSEMI, onsemi_addrs}, {SENSOR_OMNIVISION, omni_addrs},
21-
{SENSOR_GALAXYCORE, gc_addrs}, {SENSOR_SOI, soi_addrs}, {0, NULL}};
18+
sensor_addr_t ingenic_possible_i2c_addrs[] = {{SENSOR_SONY, sony_addrs},
19+
{SENSOR_SMARTSENS, ssens_addrs},
20+
{SENSOR_ONSEMI, onsemi_addrs},
21+
{SENSOR_OMNIVISION, omni_addrs},
22+
{SENSOR_GALAXYCORE, gc_addrs},
23+
{SENSOR_SOI, soi_addrs},
24+
{0, NULL}};
2225

2326
typedef unsigned char uint8;
2427
typedef unsigned short uint16;
@@ -219,8 +222,7 @@ bool ingenic_detect_cpu(char *chip_name) {
219222
static unsigned long ingenic_media_mem() {
220223
char buf[256];
221224

222-
if (!get_regex_line_from_file("/proc/cmdline", "rmem=([0-9x]+)", buf,
223-
sizeof(buf)))
225+
if (!line_from_file("/proc/cmdline", "rmem=([0-9x]+)", buf, sizeof(buf)))
224226
return 0;
225227
return strtoul(buf, NULL, 10);
226228
}
@@ -233,8 +235,8 @@ unsigned long ingenic_totalmem(unsigned long *media_mem) {
233235
float ingenic_get_temp() {
234236
float ret = -237.0;
235237
char buf[16];
236-
if (get_regex_line_from_file("/sys/class/thermal/thermal_zone0/temp",
237-
"(.+)", buf, sizeof(buf))) {
238+
if (line_from_file("/sys/class/thermal/thermal_zone0/temp", "(.+)", buf,
239+
sizeof(buf))) {
238240
ret = strtof(buf, NULL);
239241
}
240242
return ret;

src/hal/novatek.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ sensor_addr_t novatek_possible_i2c_addrs[] = {
2424
bool novatek_detect_cpu(char *chip_name) {
2525
char buf[256];
2626

27-
if (!get_regex_line_from_file("/proc/device-tree/model",
28-
"Novatek ([A-Z]+[0-9]+)", buf, sizeof(buf)))
27+
if (!line_from_file("/proc/device-tree/model", "Novatek ([A-Z]+[0-9]+)",
28+
buf, sizeof(buf)))
2929
return false;
3030
strcpy(chip_name, buf);
3131
return true;
@@ -34,9 +34,8 @@ bool novatek_detect_cpu(char *chip_name) {
3434
static unsigned long novatek_media_mem() {
3535
char buf[256];
3636

37-
if (!get_regex_line_from_file("/proc/hdal/comm/info",
38-
"DDR[0-9]:.+size = ([0-9A-Fx]+)", buf,
39-
sizeof(buf)))
37+
if (!line_from_file("/proc/hdal/comm/info",
38+
"DDR[0-9]:.+size = ([0-9A-Fx]+)", buf, sizeof(buf)))
4039
return 0;
4140
return strtoul(buf, NULL, 16) / 1024;
4241
}
@@ -49,8 +48,8 @@ unsigned long novatek_totalmem(unsigned long *media_mem) {
4948
float novatek_get_temp() {
5049
float ret = -237.0;
5150
char buf[16];
52-
if (get_regex_line_from_file("/sys/class/thermal/thermal_zone0/temp",
53-
"(.+)", buf, sizeof(buf))) {
51+
if (line_from_file("/sys/class/thermal/thermal_zone0/temp", "(.+)", buf,
52+
sizeof(buf))) {
5453
ret = strtof(buf, NULL);
5554
}
5655
return ret;

src/hal/rockchip.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ sensor_addr_t rockchip_possible_i2c_addrs[] = {
2323
bool rockchip_detect_cpu(char *chip_name) {
2424
char buf[256];
2525

26-
if (!get_regex_line_from_file("/proc/device-tree/compatible",
27-
"rockchip,(r[kv][0-9]+)", buf, sizeof(buf)))
26+
if (!line_from_file("/proc/device-tree/compatible",
27+
"rockchip,(r[kv][0-9]+)", buf, sizeof(buf)))
2828
return false;
2929
strcpy(chip_name, buf);
3030
return true;
@@ -74,8 +74,8 @@ unsigned long rockchip_totalmem(unsigned long *media_mem) {
7474
float rockchip_get_temp() {
7575
float ret = -237.0;
7676
char buf[16];
77-
if (get_regex_line_from_file("/sys/class/thermal/thermal_zone0/temp",
78-
"(.+)", buf, sizeof(buf))) {
77+
if (line_from_file("/sys/class/thermal/thermal_zone0/temp", "(.+)", buf,
78+
sizeof(buf))) {
7979
ret = strtof(buf, NULL);
8080
}
8181
return (float)ret / 1000;

src/hal/sstar.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ bool sstar_detect_cpu(char *chip_name) {
5656
static unsigned long sstar_media_mem() {
5757
char buf[256];
5858

59-
if (!get_regex_line_from_file("/proc/cmdline",
60-
"mma_heap=.+sz=(0x[0-9A-Fa-f]+)", buf,
61-
sizeof(buf)))
59+
if (!line_from_file("/proc/cmdline", "mma_heap=.+sz=(0x[0-9A-Fa-f]+)", buf,
60+
sizeof(buf)))
6261
return 0;
6362
return strtoul(buf, NULL, 16) / 1024;
6463
}
@@ -83,8 +82,8 @@ static void sstar_hal_cleanup() {}
8382
float sstar_get_temp() {
8483
float ret = -237.0;
8584
char buf[16];
86-
if (get_regex_line_from_file("/sys/class/mstar/msys/TEMP_R",
87-
"Temperature\\s+(.+)", buf, sizeof(buf))) {
85+
if (line_from_file("/sys/class/mstar/msys/TEMP_R", "Temperature\\s+(.+)",
86+
buf, sizeof(buf))) {
8887
ret = strtof(buf, NULL);
8988
}
9089
return ret;

src/hal/tegra.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ static int i2c_no_change_addr(int fd, unsigned char addr) {
4545
static void chip_properties(cJSON *j_inner) {
4646
char buf[256];
4747

48-
if (!get_regex_line_from_file("/proc/device-tree/model", "NVIDIA (.+)", buf,
49-
sizeof(buf)))
48+
if (!line_from_file("/proc/device-tree/model", "NVIDIA (.+)", buf,
49+
sizeof(buf)))
5050
return;
5151

5252
ADD_PARAM("board", buf);
@@ -55,9 +55,8 @@ static void chip_properties(cJSON *j_inner) {
5555
static void firmware_props(cJSON *j_inner) {
5656
char buf[1024];
5757

58-
if (get_regex_line_from_file("/sys/class/tegra-firmware/versions",
59-
"Firmware timestamp: (.+)", buf,
60-
sizeof(buf))) {
58+
if (line_from_file("/sys/class/tegra-firmware/versions",
59+
"Firmware timestamp: (.+)", buf, sizeof(buf))) {
6160
ADD_PARAM("tegra-firmware", buf);
6261
}
6362
}

0 commit comments

Comments
 (0)