On Thu, Feb 13, 2020 at 06:07:01PM +0100, Martin Pieuchot wrote:
> On 13/02/20(Thu) 16:53, Visa Hankala wrote:
> > On Thu, Feb 13, 2020 at 12:00:35PM +0100, Martin Pieuchot wrote:
> > > These structures are only used by autoconf(9) and don't need to be
> > > modified.  Some subsystems already define most of them as 'const'.
> > > Diff below turn all the remaining one as such.
> > > 
> > > Only a single driver, de(4), needed a modification apart from adding
> > > the const: removing a forward definition fixed it ;)
> > > 
> > > Built for all archs, I tested i386, amd64 and sparc64.
> > > 
> > > Ok?
> > 
> > No, RAMDISK build fails.
> > 
> > /usr/src/sys/dev/rd.c:87:15: error: assigning to 'struct cfattach *' from 
> > 'const struct cfattach *' discards qualifiers 
> > [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
> >         cf.cf_attach = &rd_ca;
> >                      ^ ~~~~~~
> 
> Removing const from rd(4) fixed it here in my tree.  Thanks!
>  
> > I wonder if this constification should also be reflected in the output
> > of config(8).
> 
> What do you mean?

The program generates file ioconf.c that contains lines like these:

extern struct cfattach nsphy_ca;
extern struct cfattach nsphyter_ca;
extern struct cfattach inphy_ca;
extern struct cfattach iophy_ca;
extern struct cfattach rlphy_ca;
extern struct cfattach lxtphy_ca;
extern struct cfattach ukphy_ca;
extern struct cfattach brgphy_ca;
extern struct cfattach rgephy_ca;
extern struct cfattach ciphy_ca;
extern struct cfattach scsibus_ca;
extern struct cfattach cd_ca;
extern struct cfattach sd_ca;

These are non-const even though the actual struct instances are
read-only. Later in the same file, the struct cfdata array references
these structs through non-const pointers. This has worked so far, but
the situation is not ideal because the compiler makes wrong assumptions.

Reply via email to