@@ -21,7 +21,7 @@ static uint32_t parse_processor_number(
21
21
22
22
if (processor_length == 0 ) {
23
23
cpuinfo_log_warning ("Processor number in /proc/cpuinfo is ignored: string is empty" );
24
- return 0 ;
24
+ return -1 ;
25
25
}
26
26
27
27
uint32_t processor_number = 0 ;
@@ -45,7 +45,7 @@ static void parse_isa(
45
45
struct cpuinfo_riscv_linux_processor processor [restrict static 1 ])
46
46
{
47
47
const size_t isa_length = (size_t ) (isa_end - isa_start );
48
- if (!(memcmp (isa_start , "rv32" , 4 ) == 0 || memcmp (isa_start , "rv64" , 4 ) == 0 )) {
48
+ if (isa_length < 4 || !(memcmp (isa_start , "rv32" , 4 ) == 0 || memcmp (isa_start , "rv64" , 4 ) == 0 )) {
49
49
cpuinfo_log_error ("Invalid isa format in /proc/cpuinfo: %.*s. It should start with either `rv32` or `rv64`" ,
50
50
(int ) (isa_length ), isa_start );
51
51
return ;
@@ -178,8 +178,8 @@ static bool parse_line(
178
178
}
179
179
/* Skip line if no ':' separator was found. */
180
180
if (separator == line_end ) {
181
- cpuinfo_log_info ("Line %.*s in /proc/cpuinfo is ignored: key/value separator ':' not found" ,
182
- (int ) (line_end - line_start ), line_start );
181
+ cpuinfo_log_warning ("Line %.*s in /proc/cpuinfo is ignored: key/value separator ':' not found" ,
182
+ (int ) (line_end - line_start ), line_start );
183
183
return true;
184
184
}
185
185
@@ -238,13 +238,6 @@ static bool parse_line(
238
238
goto unknown ;
239
239
}
240
240
break ;
241
- case 4 :
242
- if (memcmp (line_start , "hart" , key_length ) == 0 ) {
243
- // Do nothing
244
- } else {
245
- goto unknown ;
246
- }
247
- break ;
248
241
case 5 :
249
242
if (memcmp (line_start , "uarch" , key_length ) == 0 ) {
250
243
parse_uarch (value_start , value_end , processor );
@@ -255,7 +248,10 @@ static bool parse_line(
255
248
case 9 :
256
249
if (memcmp (line_start , "processor" , key_length ) == 0 ) {
257
250
const uint32_t new_processor_index = parse_processor_number (value_start , value_end );
258
- if (new_processor_index < processor_index ) {
251
+ if (new_processor_index < 0 ) {
252
+ /* Strange: empty string */
253
+ break ;
254
+ } else if (new_processor_index < processor_index ) {
259
255
/* Strange: decreasing processor number */
260
256
cpuinfo_log_warning (
261
257
"unexpectedly low processor number %" PRIu32 " following processor %" PRIu32 " in /proc/cpuinfo" ,
@@ -280,6 +276,8 @@ static bool parse_line(
280
276
}
281
277
break ;
282
278
default :
279
+ // Do nothing
280
+ break ;
283
281
unknown :
284
282
cpuinfo_log_debug ("unknown /proc/cpuinfo key: %.*s" , (int ) key_length , line_start );
285
283
}
0 commit comments