* [Cluster-devel] [PATCH gfs2-utils] don't use "void*" in arithmetic
@ 2009-06-22 20:33 Jim Meyering
2009-06-22 20:35 ` David Teigland
0 siblings, 1 reply; 4+ messages in thread
From: Jim Meyering @ 2009-06-22 20:33 UTC (permalink / raw)
To: cluster-devel.redhat.com
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 ;-):
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Cluster-devel] [PATCH gfs2-utils] don't use "void*" in arithmetic
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
2009-06-22 20:45 ` Jim Meyering
2009-06-22 21:22 ` Fabio M. Di Nitto
0 siblings, 2 replies; 4+ messages in thread
From: David Teigland @ 2009-06-22 20:35 UTC (permalink / raw)
To: cluster-devel.redhat.com
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
^ permalink raw reply [flat|nested] 4+ messages in thread* [Cluster-devel] [PATCH gfs2-utils] don't use "void*" in arithmetic
2009-06-22 20:35 ` David Teigland
@ 2009-06-22 20:45 ` Jim Meyering
2009-06-22 21:22 ` Fabio M. Di Nitto
1 sibling, 0 replies; 4+ messages in thread
From: Jim Meyering @ 2009-06-22 20:45 UTC (permalink / raw)
To: cluster-devel.redhat.com
David Teigland wrote:
> 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);
Thanks for the heads-up.
Avoiding casts is nice, but not a big deal here.
The const-adding parts of the patch are worth keeping, though.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Cluster-devel] [PATCH gfs2-utils] don't use "void*" in arithmetic
2009-06-22 20:35 ` David Teigland
2009-06-22 20:45 ` Jim Meyering
@ 2009-06-22 21:22 ` Fabio M. Di Nitto
1 sibling, 0 replies; 4+ messages in thread
From: Fabio M. Di Nitto @ 2009-06-22 21:22 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Mon, 2009-06-22 at 15:35 -0500, David Teigland wrote:
> 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);
Yes the idea is to sync them all, but master is lower priority at the
moment vs S3 release.
master just got all the build flags required to show all of the same
warnings as in S3, so it's going to be easier to spot what needs to be
cherry picked.
Fabio
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-22 21:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2009-06-22 20:45 ` Jim Meyering
2009-06-22 21:22 ` Fabio M. Di Nitto
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.