public inbox for lvm2-cvs@sourceware.org help / color / mirror / Atom feed
From: zkabelac@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2 ./WHATS_NEW daemons/dmeventd/dmeventd.c d ... Date: Mon, 25 Oct 2010 11:57:00 -0000 [thread overview] Message-ID: <20101025115708.2744.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-10-25 11:57:07 Modified files: . : WHATS_NEW daemons/dmeventd: dmeventd.c libdevmapper-event.c Log message: Fix clang warning for ntohl(*((uint32_t *)buf)) We cast (char*) to (uint32_t*) that changes alignment requierements. For our case the code has been correct as alloca() returns properly aligned buffer, however this patch make it cleaner and more readable and avoids warning generation. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1769&r2=1.1770 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/libdevmapper-event.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36 --- LVM2/WHATS_NEW 2010/10/25 11:20:54 1.1769 +++ LVM2/WHATS_NEW 2010/10/25 11:57:06 1.1770 @@ -1,5 +1,6 @@ Version 2.02.75 - ===================================== + Fix warning for changed alignment requirements for dmeventd read/write func. Add global/metadata_read_only to use unrepaired metadata in read-only cmds. Don't take write lock in vgchange --refresh, --poll or --monitor. Skip dm devices in scan if they contain only error targets or are empty. --- LVM2/daemons/dmeventd/dmeventd.c 2010/10/20 15:12:12 1.67 +++ LVM2/daemons/dmeventd/dmeventd.c 2010/10/25 11:57:07 1.68 @@ -1300,9 +1300,9 @@ unsigned bytes = 0; int ret = 0; fd_set fds; - int header = 1; size_t size = 2 * sizeof(uint32_t); /* status + size */ - char *buf = alloca(size); + uint32_t *header = alloca(size); + char *buf = (char *)header; msg->data = NULL; @@ -1326,9 +1326,9 @@ ret = read(fifos->client, buf + bytes, size - bytes); bytes += ret > 0 ? ret : 0; - if (bytes == 2 * sizeof(uint32_t) && header) { - msg->cmd = ntohl(*((uint32_t *) buf)); - msg->size = ntohl(*((uint32_t *) buf + 1)); + if (header && (bytes == 2 * sizeof(uint32_t))) { + msg->cmd = ntohl(header[0]); + msg->size = ntohl(header[1]); buf = msg->data = dm_malloc(msg->size); size = msg->size; bytes = 0; @@ -1356,10 +1356,11 @@ fd_set fds; size_t size = 2 * sizeof(uint32_t) + msg->size; - char *buf = alloca(size); + uint32_t *header = alloca(size); + char *buf = (char *)header; - *((uint32_t *)buf) = htonl(msg->cmd); - *((uint32_t *)buf + 1) = htonl(msg->size); + header[0] = htonl(msg->cmd); + header[1] = htonl(msg->size); if (msg->data) memcpy(buf + 2 * sizeof(uint32_t), msg->data, msg->size); --- LVM2/daemons/dmeventd/libdevmapper-event.c 2010/10/20 15:12:12 1.35 +++ LVM2/daemons/dmeventd/libdevmapper-event.c 2010/10/25 11:57:07 1.36 @@ -230,8 +230,8 @@ fd_set fds; struct timeval tval = { 0, 0 }; size_t size = 2 * sizeof(uint32_t); /* status + size */ - char *buf = alloca(size); - int header = 1; + uint32_t *header = alloca(size); + char *buf = (char *)header; while (bytes < size) { for (i = 0, ret = 0; (i < 20) && (ret < 1); i++) { @@ -262,9 +262,9 @@ } bytes += ret; - if (bytes == 2 * sizeof(uint32_t) && header) { - msg->cmd = ntohl(*((uint32_t *)buf)); - msg->size = ntohl(*((uint32_t *)buf + 1)); + if (header && (bytes == 2 * sizeof(uint32_t))) { + msg->cmd = ntohl(header[0]); + msg->size = ntohl(header[1]); buf = msg->data = dm_malloc(msg->size); size = msg->size; bytes = 0; @@ -288,12 +288,13 @@ fd_set fds; size_t size = 2 * sizeof(uint32_t) + msg->size; - char *buf = alloca(size); + uint32_t *header = alloca(size); + char *buf = (char *)header; char drainbuf[128]; struct timeval tval = { 0, 0 }; - *((uint32_t *)buf) = htonl(msg->cmd); - *((uint32_t *)buf + 1) = htonl(msg->size); + header[0] = htonl(msg->cmd); + header[1] = htonl(msg->size); memcpy(buf + 2 * sizeof(uint32_t), msg->data, msg->size); /* drain the answer fifo */ @@ -323,8 +324,7 @@ } } while (ret < 1); - ret = write(fifos->client, ((char *) buf) + bytes, - size - bytes); + ret = write(fifos->client, buf + bytes, size - bytes); if (ret < 0) { if ((errno == EINTR) || (errno == EAGAIN)) continue;
reply other threads:[~2010-10-25 11:57 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20101025115708.2744.qmail@sourceware.org \ --to=zkabelac@sourceware.org \ --cc=lvm-devel@redhat.com \ --cc=lvm2-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).