@@ -113,6 +113,9 @@ static ze_result_t enumerate_zes_devices(void)
113113 }
114114
115115 zes_handles = calloc (count , sizeof (zes_device_handle_t ));
116+ if (zes_handles == NULL ) {
117+ return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY ;
118+ }
116119
117120 res = zesDeviceGet (handle , & count , zes_handles );
118121 if (res != ZE_RESULT_SUCCESS ) {
@@ -355,7 +358,7 @@ bool zes_device_bus_is_healthy(char* bdf_address, uint32_t* error)
355358double zes_device_temp_max (char * bdf_address , char * sensor , uint32_t * error )
356359{
357360 if (getenv ("UNITTEST" ) != NULL ) {
358- return -999.0 ;
361+ return TEMP_ERROR_RET_VAL ;
359362 }
360363
361364 uint32_t requestedType = 0 ;
@@ -368,7 +371,7 @@ double zes_device_temp_max(char* bdf_address, char* sensor, uint32_t* error)
368371 } else {
369372 * error = ZE_RESULT_ERROR_INVALID_ARGUMENT ;
370373
371- return -999.0 ;
374+ return TEMP_ERROR_RET_VAL ;
372375 }
373376
374377 print_log (LOG_DEBUG , "Fetch %s temperature for %s\n" , sensor , bdf_address );
@@ -378,31 +381,31 @@ double zes_device_temp_max(char* bdf_address, char* sensor, uint32_t* error)
378381 if (res != ZE_RESULT_SUCCESS ) {
379382 * error = res ;
380383
381- return -999.0 ;
384+ return TEMP_ERROR_RET_VAL ;
382385 }
383386 }
384387
385388 zes_device_handle_t handle = retrieve_handle_for_bdf (bdf_address );
386389 if (handle == 0 ) {
387390 * error = ZE_RESULT_ERROR_UNKNOWN ;
388391
389- return -999.0 ;
392+ return TEMP_ERROR_RET_VAL ;
390393 }
391394
392395 uint32_t count = 0 ;
393396 ze_result_t res = zesDeviceEnumTemperatureSensors (handle , & count , NULL );
394397 if (res != ZE_RESULT_SUCCESS || count == 0 ) {
395398 * error = res ;
396399
397- return -999.0 ;
400+ return TEMP_ERROR_RET_VAL ;
398401 }
399402
400403 zes_temp_handle_t tempHandles [count ];
401404 res = zesDeviceEnumTemperatureSensors (handle , & count , tempHandles );
402405 if (res != ZE_RESULT_SUCCESS ) {
403406 * error = res ;
404407
405- return -999.0 ;
408+ return TEMP_ERROR_RET_VAL ;
406409 }
407410
408411 for (uint32_t i = 0 ; i < count ; ++ i ) {
@@ -412,7 +415,7 @@ double zes_device_temp_max(char* bdf_address, char* sensor, uint32_t* error)
412415 if (res != ZE_RESULT_SUCCESS ) {
413416 * error = res ;
414417
415- return -999.0 ;
418+ return TEMP_ERROR_RET_VAL ;
416419 }
417420
418421 if (props .type != requestedType ) {
@@ -424,7 +427,7 @@ double zes_device_temp_max(char* bdf_address, char* sensor, uint32_t* error)
424427 if (res != ZE_RESULT_SUCCESS ) {
425428 * error = res ;
426429
427- return -999.0 ;
430+ return TEMP_ERROR_RET_VAL ;
428431 }
429432
430433 print_log (LOG_DEBUG , "> Temperature: %.1f\n" , tempCelsius );
@@ -434,5 +437,5 @@ double zes_device_temp_max(char* bdf_address, char* sensor, uint32_t* error)
434437
435438 * error = ZE_RESULT_ERROR_NOT_AVAILABLE ;
436439
437- return -999.0 ;
440+ return TEMP_ERROR_RET_VAL ;
438441}
0 commit comments