Skip to contentSkip to conversation

Improve timer_create failure message

PATCH In review Gianfranco Trad 4 participants 6 messages Aug 29, 2024 – Sep 30, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve timer_create failure message

Improve timer_create failure message to give more information to the user.

---
 tools/testing/selftests/timers/alarmtimer-suspend.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/timers/alarmtimer-suspend.c +3 -2
index ad52e608b88e..74acdb87d4f4 100644
@@ -28,6 +28,7 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include <errno.h>
 #include "../kselftest.h"
 
 #define CLOCK_REALTIME			0
@@ -142,8 +143,8 @@ int main(void)
 
 		alarmcount = 0;
 		if (timer_create(alarm_clock_id, &se, &tm1) == -1) {
-			printf("timer_create failed, %s unsupported?\n",
-					clockstring(alarm_clock_id));
+			printf("timer_create failed, %s unsupported?: %s\n",
+					clockstring(alarm_clock_id), strerror(errno));
 			break;
 		}
 
Signature · 1 line
2.43.0
#1 lore raw

On Thu, Aug 29 2024 at 16:25, Gianfranco Trad wrote:

Please add a proper subsystem prefix to the subject.

                                                                                                                                                                                                                                                                                                                               git log --oneline $FILE                                                                                                                                                                                                                                                                                                      

gives you a decent hint

Thanks,

tglx

#2 lore raw

PATCH 1/1 selftests: timers: improve timer_create failure message

improve timer_create failure message with strerror() function to give more information to the user.

---
 tools/testing/selftests/timers/alarmtimer-suspend.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/timers/alarmtimer-suspend.c +3 -2
index ad52e608b88e..74acdb87d4f4 100644
@@ -28,6 +28,7 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <pthread.h>
+#include <errno.h>
 #include "../kselftest.h"
 
 #define CLOCK_REALTIME			0
@@ -142,8 +143,8 @@ int main(void)
 
 		alarmcount = 0;
 		if (timer_create(alarm_clock_id, &se, &tm1) == -1) {
-			printf("timer_create failed, %s unsupported?\n",
-					clockstring(alarm_clock_id));
+			printf("timer_create failed, %s unsupported?: %s\n",
+					clockstring(alarm_clock_id), strerror(errno));
 			break;
 		}
 
Signature · 1 line
2.43.0
maintainer
#3 lore raw

Re: [PATCH] selftests: timers: improve timer_create failure message

Quoted 21 lines · Gianfranco Trad

improve timer_create failure message with strerror() function to give more information to the user.

---
  tools/testing/selftests/timers/alarmtimer-suspend.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/timers/alarmtimer-suspend.c +1 -0
index ad52e608b88e..74acdb87d4f4 100644
@@ -28,6 +28,7 @@
  #include <signal.h>
  #include <stdlib.h>
  #include <pthread.h>
+#include <errno.h>
  #include "../kselftest.h"
 
  #define CLOCK_REALTIME			0

tools/testing/selftests/timers/alarmtimer-suspend.c int main(void) · line 150

Quoted 10 lines
tools/testing/selftests/timers/alarmtimer-suspend.c +2 -2
@@ -142,8 +143,8 @@ int main(void)
 
  		alarmcount = 0;
  		if (timer_create(alarm_clock_id, &se, &tm1) == -1) {
-			printf("timer_create failed, %s unsupported?\n",
-					clockstring(alarm_clock_id));
+			printf("timer_create failed, %s unsupported?: %s\n",
+					clockstring(alarm_clock_id), strerror(errno));
  			break;
  		}
 

Jon, Does this look good to you? I can pick this up if you okay with this change.

thanks,
-- Shuah

maintainer Acked-by
#4 lore raw

Re: [PATCH] selftests: timers: improve timer_create failure message

Quoted 24 lines · Shuah Khan
Quoted 22 lines · Gianfranco Trad

improve timer_create failure message with strerror() function to give more information to the user.

---
  tools/testing/selftests/timers/alarmtimer-suspend.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
tools/testing/selftests/timers/alarmtimer-suspend.c +1 -0
index ad52e608b88e..74acdb87d4f4 100644
@@ -28,6 +28,7 @@
  #include <signal.h>
  #include <stdlib.h>
  #include <pthread.h>
+#include <errno.h>
  #include "../kselftest.h"
 
  #define CLOCK_REALTIME                      0
@@ -142,8 +143,8 @@ int main(void)
 
Quoted 12 lines

tools/testing/selftests/timers/alarmtimer-suspend.c int main(void) · line 150

Quoted 9 lines
tools/testing/selftests/timers/alarmtimer-suspend.c +2 -2
              alarmcount = 0;
              if (timer_create(alarm_clock_id, &se, &tm1) == -1) {
-                     printf("timer_create failed, %s unsupported?\n",
-                                     clockstring(alarm_clock_id));
+                     printf("timer_create failed, %s unsupported?: %s\n",
+                                     clockstring(alarm_clock_id), strerror(errno));
                      break;
              }
 

Jon, Does this look good to you? I can pick this up if you okay with this change.

No objection from me, sorry this slipped by me.

maintainer
#5 lore raw

Re: [PATCH] selftests: timers: improve timer_create failure message

Quoted 9 lines · John Stultz
Quoted 4 lines · Shuah Khan

Jon, Does this look good to you? I can pick this up if you okay with this change.

No objection from me, sorry this slipped by me.

Thank you. Applied to linux-kselftest next for Linux 6.13-rc1

thanks,
-- Shuah