Fix nxstyle warning

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-01-01 00:49:00 +08:00 committed by Brennan Ashton
parent 625832aa59
commit eff52fefcf

View File

@ -127,7 +127,8 @@ static void *sender_thread(void *arg)
status = mq_send(g_send_mqfd, msg_buffer, TEST_MSGLEN, 42); status = mq_send(g_send_mqfd, msg_buffer, TEST_MSGLEN, 42);
if (status < 0) if (status < 0)
{ {
printf("sender_thread: ERROR mq_send failure=%d on msg %d\n", status, i); printf("sender_thread: ERROR mq_send failure=%d on msg %d\n",
status, i);
nerrors++; nerrors++;
} }
else else
@ -199,7 +200,8 @@ static void *receiver_thread(void *arg)
if (errno != EINTR) if (errno != EINTR)
{ {
printf("receiver_thread: ERROR mq_receive failure on msg %d, errno=%d\n", i, errno); printf("receiver_thread: ERROR mq_receive failure on msg %d, "
"errno=%d\n", i, errno);
nerrors++; nerrors++;
} }
else else
@ -209,26 +211,32 @@ static void *receiver_thread(void *arg)
} }
else if (nbytes != TEST_MSGLEN) else if (nbytes != TEST_MSGLEN)
{ {
printf("receiver_thread: mq_receive return bad size %d on msg %d\n", nbytes, i); printf("receiver_thread: "
"mq_receive return bad size %d on msg %d\n",
nbytes, i);
nerrors++; nerrors++;
} }
else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0) else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0)
{ {
int j; int j;
printf("receiver_thread: mq_receive returned corrupt message on msg %d\n", i); printf("receiver_thread: "
"mq_receive returned corrupt message on msg %d\n", i);
printf("receiver_thread: i Expected Received\n"); printf("receiver_thread: i Expected Received\n");
for (j = 0; j < TEST_MSGLEN - 1; j++) for (j = 0; j < TEST_MSGLEN - 1; j++)
{ {
if (isprint(msg_buffer[j])) if (isprint(msg_buffer[j]))
{ {
printf("receiver_thread: %2d %02x (%c) %02x (%c)\n", printf("receiver_thread: "
j, TEST_MESSAGE[j], TEST_MESSAGE[j], msg_buffer[j], msg_buffer[j]); "%2d %02x (%c) %02x (%c)\n",
j, TEST_MESSAGE[j], TEST_MESSAGE[j],
msg_buffer[j], msg_buffer[j]);
} }
else else
{ {
printf("receiver_thread: %2d %02x (%c) %02x\n", printf("receiver_thread: "
"%2d %02x (%c) %02x\n",
j, TEST_MESSAGE[j], TEST_MESSAGE[j], msg_buffer[j]); j, TEST_MESSAGE[j], TEST_MESSAGE[j], msg_buffer[j]);
} }
} }
@ -283,13 +291,15 @@ void mqueue_test(void)
status = pthread_attr_init(&attr); status = pthread_attr_init(&attr);
if (status != 0) if (status != 0)
{ {
printf("mqueue_test: pthread_attr_init failed, status=%d\n", status); printf("mqueue_test: pthread_attr_init failed, status=%d\n",
status);
} }
status = pthread_attr_setstacksize(&attr, STACKSIZE); status = pthread_attr_setstacksize(&attr, STACKSIZE);
if (status != 0) if (status != 0)
{ {
printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", status); printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n",
status);
} }
prio_min = sched_get_priority_min(SCHED_FIFO); prio_min = sched_get_priority_min(SCHED_FIFO);
@ -300,11 +310,13 @@ void mqueue_test(void)
status = pthread_attr_setschedparam(&attr, &sparam); status = pthread_attr_setschedparam(&attr, &sparam);
if (status != OK) if (status != OK)
{ {
printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n", status); printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n",
status);
} }
else else
{ {
printf("mqueue_test: Set receiver priority to %d\n", sparam.sched_priority); printf("mqueue_test: Set receiver priority to %d\n",
sparam.sched_priority);
} }
status = pthread_create(&receiver, &attr, receiver_thread, NULL); status = pthread_create(&receiver, &attr, receiver_thread, NULL);
@ -385,16 +397,17 @@ void mqueue_test(void)
pthread_join(receiver, &result); pthread_join(receiver, &result);
if (result != expected) if (result != expected)
{ {
printf("mqueue_test: ERROR receiver thread should have exited with %p\n", printf("mqueue_test: "
"ERROR receiver thread should have exited with %p\n",
expected); expected);
printf(" ERROR Instead exited with nerrors=%d\n", printf(" ERROR Instead exited with nerrors=%d\n",
(int)((intptr_t)result)); (int)((intptr_t)result));
} }
/* Message queues are global resources and persist for the life the /* Message queues are global resources and persist for the life the
* task group. The message queue opened by the sender_thread must be closed * task group. The message queue opened by the sender_thread must be
* since the sender pthread may have been canceled and may have left the * closed since the sender pthread may have been canceled and may have
* message queue open. * left the message queue open.
*/ */
if (result == PTHREAD_CANCELED && g_recv_mqfd) if (result == PTHREAD_CANCELED && g_recv_mqfd)