[sane-devel] [patch] fix SANE_Device

Oliver Rauch Oliver.Rauch@Rauch-Domain.DE
14 Nov 2004 16:29:05 +0100

Am Son, 2004-11-14 um 13.17 schrieb Henning Meier-Geinitz:
> Hi,
> On Sun, Nov 14, 2004 at 12:14:10AM +0100, Oliver Rauch wrote:
> > Please can you explain what error/warning the const produces on your
> > system?
> e.g.:
> abaton.c: In function sane_abaton_exit':
> abaton.c:902: warning: cast discards qualifiers from pointer target typ=
> abaton.c:903: warning: cast discards qualifiers from pointer target typ=
> That happens in other backends, too.
> The code is:
>       free ((void *) dev->sane.name);
>       free ((void *) dev->sane.model);     =20
> > So I think there is no need to add anything in the backend. It would =
> > enough when the backend creates a non const string and makes the poin=
> > in the struct point to the non const string - may be with a typecast,
> > but I think the typecast is not necessary.
> That's the work-around used in my backends to avoid the warnings. It
> works, but I don't think it's really clean.
> A cast doesn't seem to be necessary.
> Bye,
>   Henning

The SANE standard defines the comunication between frontend and backend.
It does not define any structs that shall be internally used by the
frontend or backend.

I think the clean appoach is that the backend handles the texts internal
as non const strings and only creats the SANE_Device struct to return
the data to the frontend. The SANE_Device struct is defined for the
purpose to transfer the data from the backend to the frontend as const
chars. When the backend has to use non const definitions then it is not
allowed to use the SANE_Device struct so it has to use it=C2=B4s own data
types and not the one of the SANE standard.