From: David Teigland <teigland@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH gfs2-utils] don't use "void*" in arithmetic
Date: Mon, 22 Jun 2009 15:35:53 -0500 [thread overview]
Message-ID: <20090622203552.GA30072@redhat.com> (raw)
In-Reply-To: <871vpcxb3z.fsf@meyering.net>
On Mon, Jun 22, 2009 at 10:33:04PM +0200, Jim Meyering wrote:
> Building gfs2-utils, I saw these warnings:
>
> main.c:21: warning: pointer of type ???void *??? used in arithmetic
> main.c:38: warning: pointer of type ???void *??? used in arithmetic
> main.c:145: warning: pointer of type ???void *??? used in arithmetic
> main.c:33: warning: pointer of type ???void *??? used in arithmetic
> main.c:50: warning: pointer of type ???void *??? used in arithmetic
>
> Here are patches that add no casts (and yes, that's a feature ;-):
We've fixed all these in the STABLE3 branch... I thought Fabio had some scheme
in mind for syncing all that work to these new trees. Both to avoid doing the
same work over again, and so we do the same thing in both. i.e. in STABLE3 I
fixed this with write(fd, (char *)buf + off, count);
>
> >From d107032f49e553061276f24016c4dc256292795d Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering@redhat.com>
> Date: Mon, 22 Jun 2009 22:12:49 +0200
> Subject: [PATCH gfs2-utils] don't use "void*" in arithmetic
>
> * group/libgfscontrol/main.c (do_read): Use an intermediate
> "char *" variable (better than a cast).
> (do_write): Likewise, and make the BUF parameter const.
> * group/gfs_control/main.c (do_write): Likewise.
> * group/gfs_controld/main.c (do_read, do_write): Likewise.
> * group/gfs_controld/gfs_daemon.h (do_write): Update prototype.
> ---
> group/gfs_control/main.c | 6 +++---
> group/gfs_controld/gfs_daemon.h | 2 +-
> group/gfs_controld/main.c | 9 +++++----
> group/libgfscontrol/main.c | 9 +++++----
> 4 files changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/group/gfs_control/main.c b/group/gfs_control/main.c
> index fe4359f..04aed09 100644
> --- a/group/gfs_control/main.c
> +++ b/group/gfs_control/main.c
> @@ -137,12 +137,13 @@ static void decode_arguments(int argc, char **argv)
> }
> }
>
> -static int do_write(int fd, void *buf, size_t count)
> +static int do_write(int fd, const void *buf, size_t count)
> {
> int rv, off = 0;
> + const char *p = buf;
>
> retry:
> - rv = write(fd, buf + off, count);
> + rv = write(fd, p + off, count);
> if (rv == -1 && errno == EINTR)
> goto retry;
> if (rv < 0)
> @@ -462,4 +463,3 @@ int main(int argc, char **argv)
> }
> return 0;
> }
> -
> diff --git a/group/gfs_controld/gfs_daemon.h b/group/gfs_controld/gfs_daemon.h
> index 7fa1837..7fbfea7 100644
> --- a/group/gfs_controld/gfs_daemon.h
> +++ b/group/gfs_controld/gfs_daemon.h
> @@ -191,7 +191,7 @@ void free_mg(struct mountgroup *mg);
>
> /* main.c */
> int do_read(int fd, void *buf, size_t count);
> -int do_write(int fd, void *buf, size_t count);
> +int do_write(int fd, const void *buf, size_t count);
> void client_dead(int ci);
> int client_add(int fd, void (*workfn)(int ci), void (*deadfn)(int ci));
> int client_fd(int ci);
> diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
> index a0b809d..65e92dc 100644
> --- a/group/gfs_controld/main.c
> +++ b/group/gfs_controld/main.c
> @@ -28,9 +28,10 @@ static void do_withdraw(char *name);
> int do_read(int fd, void *buf, size_t count)
> {
> int rv, off = 0;
> + char *p = buf;
>
> while (off < count) {
> - rv = read(fd, buf + off, count - off);
> + rv = read(fd, p + off, count - off);
> if (rv == 0)
> return -1;
> if (rv == -1 && errno == EINTR)
> @@ -42,12 +43,13 @@ int do_read(int fd, void *buf, size_t count)
> return 0;
> }
>
> -int do_write(int fd, void *buf, size_t count)
> +int do_write(int fd, const void *buf, size_t count)
> {
> int rv, off = 0;
> + const char *p = buf;
>
> retry:
> - rv = write(fd, buf + off, count);
> + rv = write(fd, p + off, count);
> if (rv == -1 && errno == EINTR)
> goto retry;
> if (rv < 0) {
> @@ -1359,4 +1361,3 @@ int dmsetup_wait;
> cpg_handle_t cpg_handle_daemon;
> int libcpg_flow_control_on;
> struct list_head withdrawn_mounts;
> -
> diff --git a/group/libgfscontrol/main.c b/group/libgfscontrol/main.c
> index 831c9e4..2890733 100644
> --- a/group/libgfscontrol/main.c
> +++ b/group/libgfscontrol/main.c
> @@ -16,9 +16,10 @@
> static int do_read(int fd, void *buf, size_t count)
> {
> int rv, off = 0;
> + char *p = buf;
>
> while (off < count) {
> - rv = read(fd, buf + off, count - off);
> + rv = read(fd, p + off, count - off);
> if (rv == 0)
> return -1;
> if (rv == -1 && errno == EINTR)
> @@ -30,12 +31,13 @@ static int do_read(int fd, void *buf, size_t count)
> return 0;
> }
>
> -static int do_write(int fd, void *buf, size_t count)
> +static int do_write(int fd, const void *buf, size_t count)
> {
> int rv, off = 0;
> + const char *p = buf;
>
> retry:
> - rv = write(fd, buf + off, count);
> + rv = write(fd, p + off, count);
> if (rv == -1 && errno == EINTR)
> goto retry;
> if (rv < 0) {
> @@ -425,4 +427,3 @@ int gfsc_fs_leave(struct gfsc_mount_args *ma, int reason)
>
> return do_write(fd, msg, sizeof(msg));
> }
> -
> --
> 1.6.3.3
next prev parent reply other threads:[~2009-06-22 20:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-22 20:33 [Cluster-devel] [PATCH gfs2-utils] don't use "void*" in arithmetic Jim Meyering
2009-06-22 20:35 ` David Teigland [this message]
2009-06-22 20:45 ` Jim Meyering
2009-06-22 21:22 ` Fabio M. Di Nitto
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=20090622203552.GA30072@redhat.com \
--to=teigland@redhat.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.