On Tue 16.Mar'10 at 18:51:41 +0100, Tamas TEVESZ wrote:
> On Tue, 16 Mar 2010, Carlos R. Mafra wrote:
> 
>  > This warning only goes away if in addition I do
>  > 
>  > diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h
>  > index 347e70e..9569b32 100644
>  > --- a/WINGs/WINGs/WUtil.h
>  > +++ b/WINGs/WINGs/WUtil.h
>  > @@ -142,7 +142,7 @@ typedef int WMCompareDataProc(const void *item1, const 
> void *item2);
>  >  typedef void WMFreeDataProc(void *data);
>  >  
>  >  /* Used by WMBag or WMArray for matching data */
>  > -typedef int WMMatchDataProc(void *item, void *cdata);
>  > +typedef int WMMatchDataProc(const void *item, const void *cdata);
> 
> this is needed, yes. or, well, it doesn't makes things any worse than 
> they are now.
> 
>  > but that opens another can of worms (various warnings in other places). 
>  > Perhaps they are worth addressing too, but I wont have time for this :-(
> 
> the problem is there anyhow, this just shuffles it a bit around. 
> neither is better or worse the other. it'll indeed be quite a task to 
> go over all these...

Ok, so I pushed the following patch to #next in the hope of guiding 
further cleanups (the first one is included in the patch). But I wont
merge it into #master untill addressing all the warnings (wmaker currently
is warning-free for me, and I would like to keep it that way).

Perhaps matchIdentifier() could even be deleted and we could use strmatch()
in its place, as they seem quite similar (why is that cast to 'WFakeGroupLeader'
in there?)

Oh my, perhaps this is not the case for matchIdentifier(), but I have this
feeling that the further one goes through the code, the more things there are
to cleanup, and one leads to the other. I hope it is not 'ad infinitum'.

---8<-----

From: Carlos R. Mafra <[email protected]>
Date: Tue, 16 Mar 2010 19:01:01 +0100
Subject: [PATCH] Constify WMMatchDataProc and fix one fallout

It addresses this warning

dialog.c: In function ‘LoadHistory’:
dialog.c:209: warning: passing argument 2 of ‘WMFindInArray’ from incompatible 
pointer type
../WINGs/WINGs/WUtil.h:455: note: expected ‘int (*)(void *, void *)’ but 
argument is of type ‘int (*)(const void *, const void *)’

but induces other in other places. One of them was this one

window.c: In function ‘wManageWindow’:
window.c:782: warning: passing argument 2 of ‘WMFindInArray’ from incompatible 
pointer type
../WINGs/WINGs/WUtil.h:455: note: expected ‘int (*)(const void *, const void 
*)’ but argument is of type ‘int (*)(void *, void *)’

which is fixed by constifying the arguments of matchIdentifier().

The other ones will hopefully be addressed later.

---
 WINGs/WINGs/WUtil.h |    2 +-
 src/window.c        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h
index 347e70e..9569b32 100644
--- a/WINGs/WINGs/WUtil.h
+++ b/WINGs/WINGs/WUtil.h
@@ -142,7 +142,7 @@ typedef int WMCompareDataProc(const void *item1, const void 
*item2);
 typedef void WMFreeDataProc(void *data);
 
 /* Used by WMBag or WMArray for matching data */
-typedef int WMMatchDataProc(void *item, void *cdata);
+typedef int WMMatchDataProc(const void *item, const void *cdata);
 
 
 
diff --git a/src/window.c b/src/window.c
index 22f97b4..7655498 100644
--- a/src/window.c
+++ b/src/window.c
@@ -564,7 +564,7 @@ static Window createFakeWindowGroupLeader(WScreen *scr, 
Window win, char *instan
        return leader;
 }
 
-static int matchIdentifier(void *item, void *cdata)
+static int matchIdentifier(const void *item, const void *cdata)
 {
        return (strcmp(((WFakeGroupLeader *) item)->identifier, (char *)cdata) 
== 0);
 }
-- 
1.7.0.2.182.ge007


-- 
To unsubscribe, send mail to [email protected].

Reply via email to