From: Alex Colomar Date: Sat, 10 Sep 2022 22:59:05 +0000 (+0200) Subject: Various pages: EXAMPLES: Use %s __func__ X-Git-Tag: man-pages-6.00~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a41b9b5ff1fdb5b06ed3ba459dffef65f1367e6;p=thirdparty%2Fman-pages.git Various pages: EXAMPLES: Use %s __func__ Instead of hardcoding the function name. Reported-by: checkpatch(1) Signed-off-by: Alex Colomar --- diff --git a/man3/makecontext.3 b/man3/makecontext.3 index ee4265b240..d8cf9284ed 100644 --- a/man3/makecontext.3 +++ b/man3/makecontext.3 @@ -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 diff --git a/man3/mallopt.3 b/man3/mallopt.3 index 61aabf7334..8880c2c289 100644 --- a/man3/mallopt.3 +++ b/man3/mallopt.3 @@ -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); } diff --git a/man3/pthread_cancel.3 b/man3/pthread_cancel.3 index 0e82b00037..e05bb5f70e 100644 --- a/man3/pthread_cancel.3 +++ b/man3/pthread_cancel.3 @@ -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 diff --git a/man3/sem_wait.3 b/man3/sem_wait.3 index 24a4abc317..4ab9e7bb06 100644 --- a/man3/sem_wait.3 +++ b/man3/sem_wait.3 @@ -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. */