@@ -21,7 +21,7 @@ static uint32_t parse_processor_number(
2121
2222	if  (processor_length  ==  0 ) {
2323		cpuinfo_log_warning ("Processor number in /proc/cpuinfo is ignored: string is empty" );
24- 		return  0 ;
24+ 		return  -1 ;
2525	}
2626
2727	uint32_t  processor_number  =  0 ;
@@ -45,7 +45,7 @@ static void parse_isa(
4545		struct  cpuinfo_riscv_linux_processor  processor [restrict static  1 ])
4646{
4747	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 )) {
4949		cpuinfo_log_error ("Invalid isa format in /proc/cpuinfo: %.*s. It should start with either `rv32` or `rv64`" ,
5050						  (int ) (isa_length ), isa_start );
5151		return ;
@@ -178,8 +178,8 @@ static bool parse_line(
178178	}
179179	/* Skip line if no ':' separator was found. */ 
180180	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 );
183183		return  true;
184184	}
185185
@@ -238,13 +238,6 @@ static bool parse_line(
238238				goto unknown ;
239239			}
240240			break ;
241- 		case  4 :
242- 			if  (memcmp (line_start , "hart" , key_length ) ==  0 ) {
243- 				// Do nothing 
244- 			} else  {
245- 				goto unknown ;
246- 			}
247- 			break ;
248241		case  5 :
249242			if  (memcmp (line_start , "uarch" , key_length ) ==  0 ) {
250243				parse_uarch (value_start , value_end , processor );
@@ -255,7 +248,10 @@ static bool parse_line(
255248		case  9 :
256249			if  (memcmp (line_start , "processor" , key_length ) ==  0 ) {
257250				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 ) {
259255					/* Strange: decreasing processor number */ 
260256					cpuinfo_log_warning (
261257						"unexpectedly low processor number %" PRIu32 " following processor %" PRIu32 " in /proc/cpuinfo" ,
@@ -280,6 +276,8 @@ static bool parse_line(
280276			}
281277			break ;
282278		default :
279+ 			// Do nothing 
280+ 			break ;
283281		unknown :
284282			cpuinfo_log_debug ("unknown /proc/cpuinfo key: %.*s" , (int ) key_length , line_start );
285283	}
0 commit comments