[sane-devel] hs2p backend

jazz_johnson at verizon.net jazz_johnson at verizon.net
Wed Nov 21 00:06:59 UTC 2007


On Tuesday 20 November 2007, m. allan noah wrote:
> On Nov 20, 2007 3:51 PM,  <jazz_johnson at verizon.net> wrote:
> > Are there any option I need to pass to configure or gcc
> > in order to generate the C90/C99 warnings?
> > I've compiled hs2p backend on both a Pentium3 x86 and
> > an amd64 x86_64 platform but can't seem to generate the warnings in your
> > logfile.
>
> at this point, i think it has something to do with my build of gcc,
> because our versions dont look all the different, but i'm no expert
> there.
>
> $ gcc -v
> Using built-in specs.
> Target: i386-redhat-linux
> Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --enable-shared --enable-threads=posix
> --enable-checking=release --with-system-zlib --enable-__cxa_atexit
> --disable-libunwind-exceptions --enable-libgcj-multifile
> --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
> --enable-java-awt=gtk --disable-dssi --enable-plugin
> --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
> --with-cpu=generic --host=i386-redhat-linux
> Thread model: posix
> gcc version 4.1.2 20070626 (Red Hat 4.1.2-13)

OK, you're using gcc-4.1.2 for a 386 host
and I was using gcc-4.1.1 for a 686  pentium host
so I've switched up to gcc-4.2.2 and set
CFLAGS="-O2 -march=i686 -pipe -Wall"
but still no warnings.
Oh well, I'm not going to rebuild my toolchain for a 386.
Warnings, I suppose, are a good thing, 
but I can't seem to get my gcc to output the ones you get,
which makes my debugging blind.


> ok. i wont have access to my 64 bit machine til latter, but attached
> is the log from the 32 bit compiler above with your latest patch.
> looks pretty good, just a couple of issues.
>
> allan

In file included from hs2p.c:95:
hs2p-scsi.c: In function 'print_bytes':
hs2p-scsi.c:70: warning: cast discards qualifiers from pointer target type

I have a debug routine for printing scsi command structs  byte-by-byte:

static void print_bytes (const void *buf, size_t bufsize)
{
  /* Your compiler doesn't like the following cast
      What should I try instead?
      By the way, is it legal to combine declaration and assignment
      or is this considered mixing declarations and code?
   */
  SANE_Byte *bp = (SANE_Byte *) buf; 
  unsigned i;
  for (i = 0; i < bufsize; i++, bp++)
    DBG (DBG_error, "%3d: 0x%02x %d\n", i, *bp, *bp);
}


______________________________________________________


hs2p-scsi.c: In function 'sense_handler':
hs2p-scsi.c:391: warning: ISO C90 forbids mixed declarations and code
FIXED: I moved (void)arg; past declarations.

_____________________________________________________

hs2p.c: In function 'sane_hs2p_exit':
hs2p.c:1396: warning: cast discards qualifiers from pointer target type
hs2p.c:1397: warning: cast discards qualifiers from pointer target type

In sane_hs2p_exit() I've changed to (I hope this finally works):
      free ((SANE_String_Const *) dev->sane.name);
      free ((SANE_String_Const *) dev->sane.model);

_______________________________________________________

hs2p.c: In function 'set_window_data':
hs2p.c:2142: warning: cast discards qualifiers from pointer target type
hs2p.c:2167: warning: cast discards qualifiers from pointer target type
hs2p.c:2197: warning: cast discards qualifiers from pointer target type
hs2p.c:2205: warning: cast discards qualifiers from pointer target type
hs2p.c:2218: warning: cast discards qualifiers from pointer target type
hs2p.c:2221: warning: cast discards qualifiers from pointer target type

I've changed paper_list[] and halftone_pattern_list[] to arrays of SANE_String_Const
and I've changed get_string_index in my macro definitions  like the following
for all my SANE_String_Const arrays (I hope this too now works):
#define get_paper_id(s)       (get_list_index( (char **)paper_list, (char *) (s) ))

________________________________________________________

hs2p.c: In function 'sane_hs2p_start':
hs2p.c:2328: warning: cast discards qualifiers from pointer target type

if (get_scan_source_id (s->val[OPT_SCAN_SOURCE].s) == 0)
should be fixed by change in macro:
#define get_scan_source_id(s) (get_list_index( ((char **)scan_source_list), (char *) (s) ))


_________________________________________________________

I hope all the warning about cast discarding qualifiers from pointer target type are now fixed:
# zgrep "(char \*\*)" hs2p_patch.gz
+#define get_paddingtype_id(s)  (get_list_index( ( (char **) paddingtype_list), (char *)(s) ))
+#define get_halftone_code_id(s)  (get_list_index( (char **)halftone_code, (char *)(s) ))
+#define get_halftone_pattern_id(s)  (get_list_index( (char **)halftone_pattern_list, (char *)(s) ))
+#define get_auto_binarization_id(s)  (get_list_index( ((char **) &auto_binarization_list[0]), (char *)(s) ))
+#define get_auto_separation_id(s)  (get_list_index( ( (char **) &auto_separation_list[0]), (char *) (s) ))
+#define get_noisematrix_id(s)    (get_list_index( ( (char **) noisematrix_list), (char *) (s) ))
+#define get_paper_id(s)       (get_list_index( (char **)paper_list, (char *) (s) ))
+#define get_scan_source_id(s) (get_list_index( ((char **)scan_source_list), (char *) (s) ))

I've placed a fresh hs2p_patch.gz and hs2p.tar.bz2 at
http://www.acjlaw.net:8080/~jeremy/Ricoh/hs2p_sane_backend/



More information about the sane-devel mailing list