Ensure these files are updated after pixma/pixma.c is changed. Do not
remove them during "make clean" or "make distclean", because they are
part of the source distribution (generated with "make dist"). Display
the relative paths in the build output.
Some of the status code checks also check that the returned data is
of the expected size. However, if they are not, it is possible to
return SANE_STATUS_GOOD in error. We should generate an appropriate
error code other than SANE_STATUS_GOOD for this case.
malloc returns NULL on error, but this code errors out on the non-NULL pointer
indicating success (which essentially makes this function always fail).
Signed-off-by: Raphael Isemann <teemperor@gmail.com>
Mainly consists of removing code for #ifdef __KERNEL__
In order to keep it really clear what code has been removed, I have
not corrected any formatting issues.
Functions called by pthread_create() have the return type (void *).
However, the return statements in read_data() use a value of type
SANE_Status rather than a pointer, which causes a compiler warning.
This return value is never actually used, so return NULL instead.
Building with --enable-silent-rules makes it easier to identify errors
or warnings in the build output. Automake provides macros for custom
rules to use, so that they will print a similar message to rules which
run the compiler or linker:
...
CC libpieusb_la-pieusb.lo
CCLD libpieusb.la
CCLD libsane-pieusb.la
CC libsane_pixma_la-pixma-s.lo
GEN pixma/pixma_sane_options.h
GEN pixma/pixma_sane_options.c
CC pixma/libpixma_la-pixma.lo
...
This does not change the current output if silent rules are disabled.
GCC warns that an unsigned value is passed to abs(), which may not be
intended. To resolve this warning, adjust the code so abs() is not used
and the behavior is more explicit.
If the weights file pathname is longer than PATH_MAX, it may be written
past the end of the buffer on the stack; or it may be truncated when it
is written to allocated memory (such that it is not null-terminated).
Adjust the code to fix both issues. Dynamically allocate memory for the
actual length of the pathname so that it is not constrained by PATH_MAX.
labs() has a signed parameter. However the argument to it here was the
difference between two unsigned values, which itself remains unsigned.
GCC warned that using this in labs() might not have the intended result.
By definition though, dwInc >= m_dwIdealGain >= dwDec, so labs() is not
even needed in this expression.
The output from the SCSI inquiry command uses fixed-length space-padded
strings, which are copied into null-terminated strings before use.
This is currently done using strncpy(), with the count parameter set to
the string's fixed length. Because a null terminator is not encountered
in the input, strncpy() does not write one in the output, and GCC warns
about potential string truncation. A null terminator is added manually,
but this is error prone (as shown by the fix for the microtek backend).
Use snprintf() instead, which guarantees a null-terminated result and
resolves the warnings from GCC.
These were intended to suppress GCC warnings about unused variables.
However, this leads to different warnings from Clang instead.
Use another approach that suppresses warnings from both compilers.