Skip to content

Commit 30edb92

Browse files
authored
Merge pull request #46 from douzzer/20220512-stderr
wolfcrypt/src/async.c: print errors to stderr, and consistently retur…
2 parents 0cfe12d + 5fdf1b0 commit 30edb92

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

wolfcrypt/src/async.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ int wc_AsyncSleep(word32 ms)
849849
} while ((ret!=0) && (errno == EINTR));
850850

851851
if (ret != 0) {
852-
printf("nanoSleep failed with code %d\n", ret);
852+
fprintf(stderr, "nanoSleep failed with code %d\n", ret);
853853
return BAD_FUNC_ARG;
854854
}
855855

@@ -879,7 +879,7 @@ int wc_AsyncThreadCreate_ex(pthread_t *thread,
879879

880880
status = pthread_attr_init(&attr);
881881
if (status !=0) {
882-
printf("%d\n", errno);
882+
fprintf(stderr, "pthread_attr_init error: %d\n", status);
883883
return ASYNC_OP_E;
884884
}
885885

@@ -938,7 +938,7 @@ int wc_AsyncThreadCreate_ex(pthread_t *thread,
938938

939939
exit_fail:
940940

941-
printf("AsyncThreadCreate error: %d\n", errno);
941+
fprintf(stderr, "AsyncThreadCreate error: %d\n", status);
942942
pthread_attr_destroy(&attr);
943943
return ASYNC_OP_E;
944944
}
@@ -1004,7 +1004,7 @@ int wc_AsyncThreadBind(pthread_t *thread, word32 logicalCore)
10041004

10051005
status = pthread_setaffinity_np(*thread, sizeof(cpu_set_t), &cpuset);
10061006
if (status != 0) {
1007-
printf("pthread_setaffinity_np, status %d, errno %d\n", status, errno);
1007+
fprintf(stderr, "pthread_setaffinity_np error: %d\n", status);
10081008
}
10091009

10101010
return status;
@@ -1030,7 +1030,7 @@ int wc_AsyncThreadKill(pthread_t *thread)
10301030

10311031
status = pthread_cancel(*thread);
10321032
if (status != 0) {
1033-
printf("pthread_cancel: Failed to cancel the thread!\n");
1033+
fprintf(stderr, "pthread_cancel fail with status %d\n", status);
10341034
}
10351035

10361036
return status;
@@ -1049,23 +1049,23 @@ int wc_AsyncThreadPrioritySet(pthread_t *thread, word32 priority)
10491049

10501050
status = pthread_getschedparam(*thread, &policy, &param);
10511051
if (status != 0) {
1052-
printf("pthread_getschedparam, failed with status %d\n", status);
1052+
fprintf(stderr, "pthread_getschedparam, failed with status %d\n", status);
10531053
return status;
10541054
}
10551055

10561056
minPrio = sched_get_priority_min(policy);
10571057
maxPrio = sched_get_priority_max(policy);
10581058

10591059
if ((priority < minPrio) || (priority > maxPrio)) {
1060-
printf("priority outside valid range\n");
1060+
fprintf(stderr, "priority %u outside valid range\n", priority);
10611061
return BAD_FUNC_ARG;
10621062
}
10631063

10641064
param.sched_priority = priority;
10651065

10661066
status = pthread_setschedparam(*thread, policy, &param);
10671067
if (status != 0) {
1068-
printf("pthread_setschedparam, failed with status %d\n", status);
1068+
fprintf(stderr, "pthread_setschedparam, failed with status %d\n", status);
10691069
return status;
10701070
}
10711071

@@ -1087,15 +1087,15 @@ int wc_AsyncThreadSetPolicyAndPriority(pthread_t *thread, word32 policy,
10871087
(policy != SCHED_FIFO) &&
10881088
(policy != SCHED_OTHER))
10891089
{
1090-
printf("policy error\n");
1090+
fprintf(stderr, "wc_AsyncThreadSetPolicyAndPriority: invalid policy %u\n", policy);
10911091
return BAD_FUNC_ARG;
10921092
}
10931093

10941094
memset(&param, 0, sizeof(param));
10951095

10961096
status = pthread_getschedparam(*thread, &policy1, &param);
10971097
if (status != 0) {
1098-
printf("pthread_getschedparam error: %d\n", errno);
1098+
fprintf(stderr, "pthread_getschedparam error: %d\n", status);
10991099
return status;
11001100
}
11011101

@@ -1110,7 +1110,7 @@ int wc_AsyncThreadSetPolicyAndPriority(pthread_t *thread, word32 policy,
11101110

11111111
status = pthread_setschedparam(*thread, policy, &param);
11121112
if (status != 0) {
1113-
printf("pthread_setschedparam error: %d\n", errno);
1113+
fprintf(stderr, "pthread_setschedparam error: %d\n", status);
11141114
return status;
11151115
}
11161116

@@ -1122,7 +1122,7 @@ int wc_AsyncThreadJoin(pthread_t *thread)
11221122
int status;
11231123
status = pthread_join(*thread, NULL);
11241124
if (status != 0) {
1125-
printf("pthread_join failed, status: %d\n", status);
1125+
fprintf(stderr, "pthread_join failed, status: %d\n", status);
11261126
}
11271127
return status;
11281128
}

0 commit comments

Comments
 (0)