[Openais] [PATCH] LINT: fix "Assignment of ssize_t to int" warnings
angus salkeld
angus.salkeld at alliedtelesis.co.nz
Tue Nov 11 10:14:56 PST 2008
committed
On Mon, 2008-11-10 at 22:56 -0700, Steven Dake wrote:
> recvmsg, sendmsg, write, read should use ssize_t return codes (ie: res
> should be ssize_t or something similar in nature) instead of the
> typecasting here. Could you fix that up and resubmit?
>
> Regards
> -steve
>
> On Mon, 2008-11-10 at 09:19 +1300, angus salkeld wrote:
> >
> > ---
> > exec/crypto.c | 4 ++--
> > exec/ipc.c | 8 ++++----
> > exec/logsys.c | 2 +-
> > lcr/uic.c | 2 +-
> > lib/util.c | 6 +++---
> > tools/corosync-keygen.c | 4 ++--
> > 6 files changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/exec/crypto.c b/exec/crypto.c
> > index 6ba5534..59ec335 100644
> > --- a/exec/crypto.c
> > +++ b/exec/crypto.c
> > @@ -1250,11 +1250,11 @@ static unsigned long rng_nix(unsigned char *buf, unsigned long len,
> > void (*callback)(void))
> > {
> > int fd;
> > - int rb;
> > + unsigned long rb;
> >
> > fd = open ("/dev/urandom", O_RDONLY);
> >
> > - rb = read (fd, buf, len);
> > + rb = (unsigned long)read (fd, buf, len);
> >
> > close (fd);
> >
> > diff --git a/exec/ipc.c b/exec/ipc.c
> > index 4a13f18..66f3761 100644
> > --- a/exec/ipc.c
> > +++ b/exec/ipc.c
> > @@ -660,7 +660,7 @@ static void ipc_flow_control (struct conn_info *conn_info)
> >
> > static int conn_info_outq_flush (struct conn_info *conn_info) {
> > struct queue *outq;
> > - int res = 0;
> > + ssize_t res = 0;
> > struct outq_item *queue_item;
> > struct msghdr msg_send;
> > struct iovec iov_send;
> > @@ -818,7 +818,7 @@ static void libais_deliver (struct conn_info *conn_info)
> > }
> >
> > retry_recv:
> > - res = recvmsg (conn_info->fd, &msg_recv, MSG_NOSIGNAL);
> > + res = (int)recvmsg (conn_info->fd, &msg_recv, MSG_NOSIGNAL);
> > if (res == -1 && errno == EINTR) {
> > goto retry_recv;
> > } else
> > @@ -1201,7 +1201,7 @@ int cs_conn_send_response (
> > iov_send.iov_len = queue_item->mlen - conn_info->byte_start;
> >
> > retry_sendmsg:
> > - res = sendmsg (conn_info->fd, &msg_send, MSG_NOSIGNAL);
> > + res = (int)sendmsg (conn_info->fd, &msg_send, MSG_NOSIGNAL);
> > if (res == -1 && errno == EINTR) {
> > goto retry_sendmsg;
> > }
> > @@ -1240,7 +1240,7 @@ retry_sendmsg:
> > iov_send.iov_base = msg;
> > iov_send.iov_len = mlen;
> > retry_sendmsg_two:
> > - res = sendmsg (conn_info->fd, &msg_send, MSG_NOSIGNAL);
> > + res = (int)sendmsg (conn_info->fd, &msg_send, MSG_NOSIGNAL);
> > if (res == -1 && errno == EINTR) {
> > goto retry_sendmsg_two;
> > }
> > diff --git a/exec/logsys.c b/exec/logsys.c
> > index ced821e..0096189 100644
> > --- a/exec/logsys.c
> > +++ b/exec/logsys.c
> > @@ -967,7 +967,7 @@ int logsys_log_rec_store (char *filename)
> > return (-1);
> > }
> >
> > - size = write (fd, flt_data, (flt_data_size + 2) * sizeof (unsigned int));
> > + size = (int)write (fd, flt_data, (flt_data_size + 2) * sizeof (unsigned int));
> > if (size != ((flt_data_size + 2) * sizeof (unsigned int))) {
> > return (-1);
> > }
> > diff --git a/lcr/uic.c b/lcr/uic.c
> > index f015e56..252f221 100755
> > --- a/lcr/uic.c
> > +++ b/lcr/uic.c
> > @@ -120,7 +120,7 @@ int uic_msg_send (int fd, char *msg)
> > #endif
> >
> > retry_send:
> > - res = sendmsg (fd, &msg_send, 0);
> > + res = (int)sendmsg (fd, &msg_send, 0);
> > if (res == -1 && errno == EINTR) {
> > goto retry_send;
> > }
> > diff --git a/lib/util.c b/lib/util.c
> > index 94085af..7193546 100644
> > --- a/lib/util.c
> > +++ b/lib/util.c
> > @@ -225,7 +225,7 @@ saRecvRetry (
> > size_t len)
> > {
> > cs_error_t error = CS_OK;
> > - int result;
> > + ssize_t result;
> > struct msghdr msg_recv;
> > struct iovec iov_recv;
> > char *rbuf = (char *)msg;
> > @@ -284,7 +284,7 @@ saSendRetry (
> > size_t len)
> > {
> > cs_error_t error = CS_OK;
> > - int result;
> > + ssize_t result;
> > struct msghdr msg_send;
> > struct iovec iov_send;
> > char *rbuf = (char *)msg;
> > @@ -368,7 +368,7 @@ cs_error_t saSendMsgRetry (
> > int iov_len)
> > {
> > cs_error_t error = CS_OK;
> > - int result;
> > + ssize_t result;
> > int total_size = 0;
> > int i;
> > int csize;
> > diff --git a/tools/corosync-keygen.c b/tools/corosync-keygen.c
> > index a45d4b0..879e1ac 100644
> > --- a/tools/corosync-keygen.c
> > +++ b/tools/corosync-keygen.c
> > @@ -63,7 +63,7 @@ int main (void) {
> > /*
> > * Read random data
> > */
> > - res = read (random_fd, key, sizeof (key));
> > + res = (int)read (random_fd, key, sizeof (key));
> > if (res == -1) {
> > perror ("Could not read /dev/random");
> > exit (1);
> > @@ -88,7 +88,7 @@ int main (void) {
> > /*
> > * Write key
> > */
> > - res = write (authkey_fd, key, sizeof (key));
> > + res = (int)write (authkey_fd, key, sizeof (key));
> > if (res == -1) {
> > perror ("Could not write /etc/ais/authkey");
> > exit (1);
> > --
> > 1.5.6
> >
> >
> > _______________________________________________
> > Openais mailing list
> > Openais at lists.linux-foundation.org
> > https://lists.linux-foundation.org/mailman/listinfo/openais
>
--
Angus Salkeld
Allied Telesis Labs Ltd.
New Zealand
More information about the Openais
mailing list