libratbox/src/commio.c: misc cleanups for compiler warnings
commio.c:2244:11: warning: variable length array used [-Wvla] commio.c:2253:29: warning: comparison of integers of different signs: 'unsigned int' and 'int' [-Wsign-compare] This use of alloca(3) is okay-ish considering the corresponding function `rb_recv_fd_buf()` already uses it too, for much the same purpose. Also remove a redundant return statement.
This commit is contained in:
parent
c41d0c0f5f
commit
a6485efda0
1 changed files with 4 additions and 3 deletions
|
@ -2241,7 +2241,7 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
|
|||
if(count > 0)
|
||||
{
|
||||
int len = CMSG_SPACE(sizeof(int) * count);
|
||||
char buf[len];
|
||||
char *buf = alloca(len);
|
||||
|
||||
msg.msg_control = buf;
|
||||
msg.msg_controllen = len;
|
||||
|
@ -2250,13 +2250,14 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
|
|||
cmsg->cmsg_type = SCM_RIGHTS;
|
||||
cmsg->cmsg_len = CMSG_LEN(sizeof(int) * count);
|
||||
|
||||
for(unsigned int i = 0; i < count; i++)
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
((int *)CMSG_DATA(cmsg))[i] = rb_get_fd(F[i]);
|
||||
}
|
||||
|
||||
msg.msg_controllen = cmsg->cmsg_len;
|
||||
return sendmsg(rb_get_fd(xF), &msg, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
return sendmsg(rb_get_fd(xF), &msg, MSG_NOSIGNAL);
|
||||
}
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue