apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Branko ─îibej <br...@xbc.nu>
Subject Re: cvs commit: apache-2.0/src/lib/aputil apu_private.hw
Date Thu, 30 Nov 2000 20:37:33 GMT
Greg Stein wrote:

> On Thu, Nov 30, 2000 at 04:03:13AM -0800, Greg Stein wrote:
> 
>> On Wed, Nov 29, 2000 at 01:55:22PM -0800, William A. Rowe, Jr. wrote:
>> 
>> Euh... those warnings are wrong. We pass in "const char **" for memcpy()'s
>> first parameters which is a "void *". The two "should be" compatible.
>> 
>> Grr... anybody have any ideas on how best to solve the problem? (seems like
>> a problem with the compiler itself)
> 
Probably, yes.

> Ooh... I may know what this is. I changed a few lines that looked like:
> 
>     char const *foo;
> 
> to the standard Apache-style: (hell, everybody's style)
> 
>     const char *foo;
> 
> Do you think that if we put a few of the decls back to the former style,
> that the warnings will go away?

No. The compiler is simply wrong. I suggest the following patch. It 
doesn't cost anything, and gets rid of the warning. An appropriate 
comment wouldn't hurt, either.

Index: apr/misc/unix/getopt.c
===================================================================
RCS file: /home/cvs/apr/misc/unix/getopt.c,v
retrieving revision 1.28
diff -u -p -r1.28 getopt.c
--- apr/misc/unix/getopt.c      2000/11/29 07:41:27     1.28
+++ apr/misc/unix/getopt.c      2000/11/30 20:35:32
@@ -51,6 +51,8 @@ static const char *pretty_path (const ch
 APR_DECLARE(apr_status_t) apr_initopt(apr_getopt_t **os, apr_pool_t *cont,
                                       int argc, const char *const *argv)
 {
+    void *argv_buff;
+
     *os = apr_palloc(cont, sizeof(apr_getopt_t));
     (*os)->cont = cont;
     (*os)->err = 1;
@@ -61,8 +63,9 @@ APR_DECLARE(apr_status_t) apr_initopt(ap
        that's the primary purpose of this function.  But people might
        want to use this function with arrays other than the main argv,
        and we shouldn't touch the caller's data.  So we copy. */
-    (*os)->argv = apr_palloc(cont, (argc + 1) * sizeof(const char *));
-    memcpy((*os)->argv, argv, argc * sizeof(const char *));
+    argv_buff = apr_palloc(cont, (argc + 1) * sizeof(const char *));
+    memcpy(argv_buff, argv, argc * sizeof(const char *));
+    (*os)->argv = argv_buff;
     (*os)->argv[argc] = NULL;

     (*os)->interleave = 0;  


-- 
Brane ─îibej
    home:   <brane@xbc.nu>             http://www.xbc.nu/brane/
    work:   <branko.cibej@hermes.si>   http://www.hermes-softlab.com/
     ACM:   <brane@acm.org>            http://www.acm.org/



Mime
View raw message