CURRENT (r253984) buildworld fails: contrib/bind9/bin/dig/dighost.c:4340:27: error: passing 'const char *' to parameter of type 'void *' discards qualifiers

2013-08-06 Thread O. Hartmann
Buildword on r253984 fails ins BIND9:


cc  -O2 -pipe -O3 -march=native
-I/usr/src/usr.sbin/pkg_install/create/../lib -pipe -O3 -std=gnu99
-Qunused-arguments -fstack-protector -Wsystem-headers -Werror -Wall
-Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes
-Wmissing-prototypes -Wpointer-arith -Wno-uninitialized
-Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int
-Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality
-Wno-unused-function -Wno-conversion -Wformat=2 -Wno-format-extra-args
-Wno-format-nonliteral -Werror
-c /usr/src/usr.sbin/pkg_install/create/perform.c --- usr.bin.all__D
--- /usr/src/usr.bin/dig/../../contrib/bind9/bin/dig/dighost.c:4340:27:
error: passing 'const char *' to parameter of type 'void *' discards
qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
isc_buffer_init(buffer, str, len);
[...]


signature.asc
Description: PGP signature


Re: const char *

1999-02-21 Thread Matthew Dillon
:don't think there's any way to get rid of the warning without changing
:the declarations.
:
:In my opinion, the use of -Wcast-qual is bogus.  Often the whole
:point of a cast is to remove a qualifier such as const.  It's one
:thing to warn when that's done implicitly, and quite another thing to
:warn when the programmer has clearly expressed his intent through the
:use of a cast.
:
:John
:-- 
:  John Polstra   j...@polstra.com

There are only a few cases where cast-qual is bogus.  99% of the warnings
it generated were quite real.  Maybe not bugs, but definitely programming
by misadventure.  Volatile and const are only going to become more
important as we get deeper into the SMP issues.  Especially volatile.
cast-qual is necessary to keep people from making bozo mistakes.

Matthew Dillon 
dil...@backplane.com


To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe freebsd-current in the body of the message



Re: const char *

1999-02-21 Thread Bruce Evans
../../dev/usb/ukbd.c: In function `ukbd_detach':
../../dev/usb/ukbd.c:373: warning: cast discards `const' from pointer
target type
...
It is a consequence of the following type definition:

(sys/bus_private.h)
struct device {
...
const char* desc;   /* driver specific description */
...
}

One problem I have is that a string like that might be produced by
concatenating a few strings together.  In the case of USB the desc is
the string returned by the device. At attach the string is created and
malloc()-ed, at detach free()-ed. 

At the sys/bus*.h (bus) level, `desc' is just a string.  It is const
mainly so that callers can pass a literal string to device_set_desc()
without getting a warning from -Wcast-qual.  Unfortunately, this prevents
the bus level from helping you keep track of how the string was created.

The warning could be avoided using a table of the original (non-const)
addresses of the (malloc()ed) strings passed to device_set_desc().
This is a bit much to avoid a harmless warning, but you would need to
do it if not all strings were malloc()ed.

The warning can be avoided by (ab)using a variant union.  I plan to use
a suitably macroised version of this to fix warnings for library functions.

Bruce


To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe freebsd-current in the body of the message



Re: const char *

1999-02-21 Thread John Polstra

Matthew Dillon wrote:

:
:In my opinion, the use of -Wcast-qual is bogus.  Often the whole
:point of a cast is to remove a qualifier such as const.  It's one
:thing to warn when that's done implicitly, and quite another thing
:to warn when the programmer has clearly expressed his intent through
:the use of a cast.

 There are only a few cases where cast-qual is bogus.  99% of
 the warnings it generated were quite real.  Maybe not bugs, but
 definitely programming by misadventure.  Volatile and const are
 only going to become more important as we get deeper into the
 SMP issues.  Especially volatile. cast-qual is necessary to keep
 people from making bozo mistakes.

I would find -Wcast-qual tolerable if it behaved just a little bit
differently.  It should allow without complaint explicit casts which
change _only_ the constness.  For example, casting from const char
* to char * explicitly would be OK.  But casting from, say, const
char * to void * would still produce a warning.  This would make it
possible to get rid of the warnings in those cases where it made sense
to cast away const (e.g., dealing with bad but standard interfaces).

The above is more or less how C++'s const_castT(x) construct
works.

John
---
  John Polstra   j...@polstra.com
  John D. Polstra  Co., Inc.Seattle, Washington USA
  Nobody ever went broke underestimating the taste of the American public.
-- H. L. Mencken


To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe freebsd-current in the body of the message



const char *

1999-02-20 Thread Nick Hibma

With the new efforts in getting rid of all the warnings in the kernel
compiles I have a problem with the following warning:

../../dev/usb/ukbd.c: In function `ukbd_detach':
../../dev/usb/ukbd.c:373: warning: cast discards `const' from pointer
target type

produced by the following two lines in the USB code:

(dev/usb/ukbd.c)
ukbd_detach(device_t self)
{
...
const char *devinfo = device_get_desc(self);
...
free((void *)devinfo, M_USB);


It is a consequence of the following type definition:

(sys/bus_private.h)
struct device {
...
const char* desc;   /* driver specific description */
...
}

One problem I have is that a string like that might be produced by
concatenating a few strings together.  In the case of USB the desc is
the string returned by the device. At attach the string is created and
malloc()-ed, at detach free()-ed. 

Anyone savvy enough to tell me what I need to change in the USB code to
get rid of the warning? 

Cheers,

Nick

FreeBSD USB Driver Development
-- 
  e-mail: n_hi...@freebsd.org
   home page: http://www.etla.net/~n_hibma/usb/usb.pl
mailing list: usb-...@egroups.com




To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe freebsd-current in the body of the message



Re: const char *

1999-02-20 Thread John Polstra
In article pine.bsf.3.96.990220224447.327a-100...@henny.plazza.it,
Nick Hibma  hi...@skylink.it wrote:
 
 With the new efforts in getting rid of all the warnings in the kernel
 compiles I have a problem with the following warning:
 
 ../../dev/usb/ukbd.c: In function `ukbd_detach':
 ../../dev/usb/ukbd.c:373: warning: cast discards `const' from pointer
 target type
 
 produced by the following two lines in the USB code:
 
 (dev/usb/ukbd.c)
 ukbd_detach(device_t self)
 {
 ...
 const char *devinfo = device_get_desc(self);
 ...
 free((void *)devinfo, M_USB);
...
 Anyone savvy enough to tell me what I need to change in the USB code to
 get rid of the warning? 

The warning comes because -Wcast-qual is on the command line.  I
don't think there's any way to get rid of the warning without changing
the declarations.

In my opinion, the use of -Wcast-qual is bogus.  Often the whole
point of a cast is to remove a qualifier such as const.  It's one
thing to warn when that's done implicitly, and quite another thing to
warn when the programmer has clearly expressed his intent through the
use of a cast.

John
-- 
  John Polstra   j...@polstra.com
  John D. Polstra  Co., Inc.Seattle, Washington USA
  Nobody ever went broke underestimating the taste of the American public.
-- H. L. Mencken


To Unsubscribe: send mail to majord...@freebsd.org
with unsubscribe freebsd-current in the body of the message