]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
Various pages: EXAMPLES: Use %s __func__
authorAlex Colomar <alx.manpages@gmail.com>
Sat, 10 Sep 2022 22:59:05 +0000 (00:59 +0200)
committerAlex Colomar <alx.manpages@gmail.com>
Mon, 12 Sep 2022 15:18:55 +0000 (17:18 +0200)
Instead of hardcoding the function name.

Reported-by: checkpatch(1)
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
man3/makecontext.3
man3/mallopt.3
man3/pthread_cancel.3
man3/sem_wait.3

index ee4265b240fbdd64a5be665a1dab97ffc9dcb356..d8cf9284ed5889e446f30c0562a5ada33223fdab 100644 (file)
@@ -182,21 +182,21 @@ static ucontext_t uctx_main, uctx_func1, uctx_func2;
 static void
 func1(void)
 {
-    printf("func1: started\en");
-    printf("func1: swapcontext(&uctx_func1, &uctx_func2)\en");
+    printf("%s: started\en", __func__);
+    printf("%s: swapcontext(&uctx_func1, &uctx_func2)\en", __func__);
     if (swapcontext(&uctx_func1, &uctx_func2) == \-1)
         handle_error("swapcontext");
-    printf("func1: returning\en");
+    printf("%s: returning\en", __func__);
 }
 
 static void
 func2(void)
 {
-    printf("func2: started\en");
-    printf("func2: swapcontext(&uctx_func2, &uctx_func1)\en");
+    printf("%s: started\en", __func__);
+    printf("%s: swapcontext(&uctx_func2, &uctx_func1)\en", __func__);
     if (swapcontext(&uctx_func2, &uctx_func1) == \-1)
         handle_error("swapcontext");
-    printf("func2: returning\en");
+    printf("%s: returning\en", __func__);
 }
 
 int
@@ -220,11 +220,11 @@ main(int argc, char *argv[])
     uctx_func2.uc_link = (argc > 1) ? NULL : &uctx_func1;
     makecontext(&uctx_func2, func2, 0);
 
-    printf("main: swapcontext(&uctx_main, &uctx_func2)\en");
+    printf("%s: swapcontext(&uctx_main, &uctx_func2)\en", __func__);
     if (swapcontext(&uctx_main, &uctx_func2) == \-1)
         handle_error("swapcontext");
 
-    printf("main: exiting\en");
+    printf("%s: exiting\en", __func__);
     exit(EXIT_SUCCESS);
 }
 .EE
index 61aabf73348aca086e6177c3481b5284ebf0ec95..8880c2c289262a0c28d387498744490bbcabb5c4 100644 (file)
@@ -588,10 +588,10 @@ main(int argc, char *argv[])
     }
 
     free(p);
-    printf("main(): returned from first free() call\en");
+    printf("%s(): returned from first free() call\en", __func__);
 
     free(p);
-    printf("main(): returned from second free() call\en");
+    printf("%s(): returned from second free() call\en", __func__);
 
     exit(EXIT_SUCCESS);
 }
index 0e82b000378e174431e8a66b9df10a0be090bfcc..e05bb5f70e91643bc1907bbf3979ecf6c87a08d7 100644 (file)
@@ -171,9 +171,9 @@ thread_func(void *ignored_argument)
     if (s != 0)
         handle_error_en(s, "pthread_setcancelstate");
 
-    printf("thread_func(): started; cancelation disabled\en");
+    printf("%s(): started; cancelation disabled\en", __func__);
     sleep(5);
-    printf("thread_func(): about to enable cancelation\en");
+    printf("%s(): about to enable cancelation\en", __func__);
 
     s = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
     if (s != 0)
@@ -185,7 +185,7 @@ thread_func(void *ignored_argument)
 
     /* Should never get here. */
 
-    printf("thread_func(): not canceled!\en");
+    printf("%s(): not canceled!\en", __func__);
     return NULL;
 }
 
@@ -204,7 +204,7 @@ main(void)
 
     sleep(2);           /* Give thread a chance to get started */
 
-    printf("main(): sending cancelation request\en");
+    printf("%s(): sending cancelation request\en", __func__);
     s = pthread_cancel(thr);
     if (s != 0)
         handle_error_en(s, "pthread_cancel");
@@ -216,9 +216,10 @@ main(void)
         handle_error_en(s, "pthread_join");
 
     if (res == PTHREAD_CANCELED)
-        printf("main(): thread was canceled\en");
+        printf("%s(): thread was canceled\en", __func__);
     else
-        printf("main(): thread wasn\(aqt canceled (shouldn\(aqt happen!)\en");
+        printf("%s(): thread wasn\(aqt canceled (shouldn\(aqt happen!)\en",
+               __func__);
     exit(EXIT_SUCCESS);
 }
 .EE
index 24a4abc3170b72202c6c97490f3b55da3211ab54..4ab9e7bb06227cd50822f45961ac279645a547e4 100644 (file)
@@ -223,7 +223,7 @@ main(int argc, char *argv[])
 
     ts.tv_sec += atoi(argv[2]);
 
-    printf("main() about to call sem_timedwait()\en");
+    printf("%s() about to call sem_timedwait()\en", __func__);
     while ((s = sem_timedwait(&sem, &ts)) == \-1 && errno == EINTR)
         continue;       /* Restart if interrupted by handler. */