On Sat, Jun 09, 2001 at 12:49:40AM -0700, Damien Neil wrote:
> On Thu, Jun 07, 2001 at 12:47:30PM -0500, Jacques A. Vidrine wrote:
> > C99 says of uintptr_t only that for any valid pointer p, the following
> > is true:
> >
> > (void *)(uintptr_t)p == (void *)p
> >
> > Likewise for intptr_t.
On Thu, Jun 07, 2001 at 12:47:30PM -0500, Jacques A. Vidrine wrote:
> C99 says of uintptr_t only that for any valid pointer p, the following
> is true:
>
> (void *)(uintptr_t)p == (void *)p
>
> Likewise for intptr_t. I read that as covering both code and data
> pointers.
C89, at least,
Oh my, and just posting these I found a couple of bugs!
:char *
:safe_replace(char **pptr, const char *s)
:{
:/*
: * Same data (also occurs if s == *ptr), nothing to do
: */
:if (*pptr) {
: if (s && strcmp(s, *pptr) == 0)
: return(*pptr);
: free(*pptr);
Here is the whole set of supporting routines.
-Matt
/*
* STRDUP.C
*
* $Backplane: backplane/src/libsupport/strdup.c,v 1.13 2001/04/03 00:03:18 dillon Exp
$
*/
#include "defs.h"
Export char *safe_strdup(const char *s);
Export char *safe_strdup_s
:OK, here's a scenario:
:
:struct validation_fun {
: const char *name;
: valfun *fun;
: int dyn;
:};
:
:This is a structure for a set of validation functions, referenced by
:name from another type of object. There are some predefined functions,
:present
>
> > Since some strings are non-constant (the are allocated) - I believe
> > the `const' qualifier in the structure declaration is incorrect.
>
> 'const' just means "I will not be modifying this"; it's a way for a
> function prototype to constrain the function's implementation.
>
Yes - it
> Since some strings are non-constant (the are allocated) - I believe
> the `const' qualifier in the structure declaration is incorrect.
'const' just means "I will not be modifying this"; it's a way for a
function prototype to constrain the function's implementation.
--
... every activity me
> E.. this was the whole point of this thread. I *can't* cast
> a (const char *) to a (char *) when using the -Wcast-qual gcc flag -
Not all -W options are equally useful and some are actively harmful.
This is one of them. There are several situations where it is
necessary to remove a quali
On Fri, Jun 08, 2001 at 03:09:53PM +0200, Assar Westerlund wrote:
> Peter Pentchev <[EMAIL PROTECTED]> writes:
> > My explanation was a reply to a suggestion to remove the 'const' in
> > the structure definition.
>
> My fault. The code that I should have shown was without the 'const'.
> With gcc
Peter Pentchev <[EMAIL PROTECTED]> writes:
> My explanation was a reply to a suggestion to remove the 'const' in
> the structure definition.
My fault. The code that I should have shown was without the 'const'.
With gcc 2.95.3 and 'gcc -O -g -Werror -Wall -W -Wcast-qual -c foo.c'
I don't get any
On Fri, Jun 08, 2001 at 03:02:56PM +0200, Assar Westerlund wrote:
> Peter Pentchev <[EMAIL PROTECTED]> writes:
> > GCC complains when I try to initialize the structure with something like:
> >
> > struct validation_fun val_init[] = {
> > {"init",valfun_init,0}
> > };
> >
>
Peter Pentchev <[EMAIL PROTECTED]> writes:
> GCC complains when I try to initialize the structure with something like:
>
> struct validation_fun val_init[] = {
> {"init",valfun_init,0}
> };
>
> This can be avoided by:
>
> struct validation_fun val_init[] = {
> {(char *)
>
> On Fri, Jun 08, 2001 at 08:51:54AM -0400, Thomas David Rivers wrote:
> > >
> > > GCC complains when I try to initialize the structure with something like:
> > >
> > > struct validation_fun val_init[] = {
> > > {"init",valfun_init,0}
> > > };
> > >
> > > This can be avoide
On Fri, Jun 08, 2001 at 08:51:54AM -0400, Thomas David Rivers wrote:
> >
> > GCC complains when I try to initialize the structure with something like:
> >
> > struct validation_fun val_init[] = {
> > {"init",valfun_init,0}
> > };
> >
> > This can be avoided by:
> >
> > st
>
> GCC complains when I try to initialize the structure with something like:
>
> struct validation_fun val_init[] = {
> {"init",valfun_init,0}
> };
>
> This can be avoided by:
>
> struct validation_fun val_init[] = {
> {(char *) (uintptr_t) "init", valfun_init,0}
On Fri, Jun 08, 2001 at 06:55:50AM -0400, Thomas David Rivers wrote:
> Peter Pentchev <[EMAIL PROTECTED]> wrote:
> >
> > On Thu, Jun 07, 2001 at 10:20:51AM -0700, John Baldwin wrote:
> > >
> > > On 07-Jun-01 Peter Pentchev wrote:
> > > > On Thu, Jun 07, 2001 at 07:07:22PM +0300, Peter Pentchev w
Peter Pentchev <[EMAIL PROTECTED]> wrote:
>
> On Thu, Jun 07, 2001 at 10:20:51AM -0700, John Baldwin wrote:
> >
> > On 07-Jun-01 Peter Pentchev wrote:
> > > On Thu, Jun 07, 2001 at 07:07:22PM +0300, Peter Pentchev wrote:
> > >> Hi,
> > >>
> > >> Is free((void *) (size_t) ptr) the only way to fr
On Thu, Jun 07, 2001 at 10:20:51AM -0700, John Baldwin wrote:
>
> On 07-Jun-01 Peter Pentchev wrote:
> > On Thu, Jun 07, 2001 at 07:07:22PM +0300, Peter Pentchev wrote:
> >> Hi,
> >>
> >> Is free((void *) (size_t) ptr) the only way to free a const whatever *ptr
> >> with WARNS=2? (or more speci
In message <[EMAIL PROTECTED]> John Baldwin writes:
: Of course, this begs the question of why you are free'ing a const. :)
Sometimes that's the only handle that you have on the object :-). I
sometimes think that changing free to be const void * is the right
answer, but that has its own set prob
On Thu, Jun 07, 2001 at 10:20:51AM -0700, John Baldwin wrote:
>
> On 07-Jun-01 Peter Pentchev wrote:
> > On Thu, Jun 07, 2001 at 07:07:22PM +0300, Peter Pentchev wrote:
> >> Hi,
> >>
> >> Is free((void *) (size_t) ptr) the only way to free a const whatever *ptr
> >> with WARNS=2? (or more speci
On 07-Jun-01 Peter Pentchev wrote:
> On Thu, Jun 07, 2001 at 07:07:22PM +0300, Peter Pentchev wrote:
>> Hi,
>>
>> Is free((void *) (size_t) ptr) the only way to free a const whatever *ptr
>> with WARNS=2? (or more specifically, with -Wcast-qual)
>
> Uhm. OK. So size_t may not be enough to ho
On Thu, Jun 07, 2001 at 07:07:22PM +0300, Peter Pentchev wrote:
> Hi,
>
> Is free((void *) (size_t) ptr) the only way to free a const whatever *ptr
> with WARNS=2? (or more specifically, with -Wcast-qual)
Uhm. OK. So size_t may not be enough to hold a pointer. What is it then -
caddr_t?
G'l
Hi,
Is free((void *) (size_t) ptr) the only way to free a const whatever *ptr
with WARNS=2? (or more specifically, with -Wcast-qual)
G'luck,
Peter
--
I've heard that this sentence is a rumor.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the
23 matches
Mail list logo