scanadf: fixes for various compilation warnings

merge-requests/2/head
Ralph Little 2021-04-06 09:27:09 -07:00
rodzic 572980c815
commit 7ebdf2cd62
3 zmienionych plików z 76 dodań i 43 usunięć

Wyświetl plik

@ -75,7 +75,7 @@ esac
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(os2.h fcntl.h unistd.h libc.h sys/time.h sys/types.h)
AC_CHECK_HEADERS(os2.h fcntl.h unistd.h libc.h sys/time.h sys/types.h sys/socket.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

Wyświetl plik

@ -211,7 +211,7 @@ sanei_w_array (Wire * w, SANE_Word * len_ptr, void **v,
|| (w->allocated_memory + len * element_size) > MAX_MEM)
{
DBG (0, "sanei_w_array: DECODE: maximum amount of allocated memory "
"exceeded (limit: %u, new allocation: %u, total: %u bytes)\n",
"exceeded (limit: %u, new allocation: %zu, total: %zu bytes)\n",
MAX_MEM, len * element_size, MAX_MEM + len * element_size);
w->status = ENOMEM;
return;
@ -289,7 +289,7 @@ sanei_w_ptr (Wire * w, void **v, WireCodecFunc w_value, size_t value_size)
if (value_size > MAX_MEM)
{
DBG (0, "sanei_w_ptr: DECODE: maximum amount of allocated memory "
"exceeded (limit: %u, new allocation: %u, total: %u bytes)\n",
"exceeded (limit: %u, new allocation: %zu, total: %zu bytes)\n",
MAX_MEM, value_size, (w->allocated_memory + value_size));
w->status = ENOMEM;
return;

Wyświetl plik

@ -50,23 +50,49 @@
#define PATH_MAX 1024
#endif
#ifndef sane_isbasicframe
#define SANE_FRAME_TEXT 10
#define SANE_FRAME_JPEG 11
#define SANE_FRAME_G31D 12
#define SANE_FRAME_G32D 13
#define SANE_FRAME_G42D 14
#define sane_strframe(f) ( (f) == SANE_FRAME_GRAY ? "gray" : \
(f) == SANE_FRAME_RGB ? "RGB" : \
(f) == SANE_FRAME_RED ? "red" : \
(f) == SANE_FRAME_GREEN ? "green" : \
(f) == SANE_FRAME_BLUE ? "blue" : \
(f) == SANE_FRAME_TEXT ? "text" : \
(f) == SANE_FRAME_JPEG ? "jpeg" : \
(f) == SANE_FRAME_G31D ? "g31d" : \
(f) == SANE_FRAME_G32D ? "g32d" : \
(f) == SANE_FRAME_G42D ? "g42d" : \
"unknown" )
const char*
sane_strframe (SANE_Frame f)
{
switch (f)
{
case SANE_FRAME_GRAY:
return "gray";
case SANE_FRAME_RGB:
return "RBG";
case SANE_FRAME_RED:
return "red";
case SANE_FRAME_GREEN:
return "green";
case SANE_FRAME_BLUE:
return "blue";
#if 0 // Not currently support by SANE
case SANE_FRAME_TEXT:
return "text";
case SANE_FRAME_JPEG:
return "jpeg";
case SANE_FRAME_G31D:
return "g31d";
case SANE_FRAME_G32D:
return "g32d";
case SANE_FRAME_G42D:
return "g42d";
#endif
default:
return "unknown";
}
}
#define sane_isbasicframe(f) ( (f) == SANE_FRAME_GRAY || \
(f) == SANE_FRAME_RGB || \
@ -74,7 +100,6 @@
(f) == SANE_FRAME_GREEN || \
(f) == SANE_FRAME_BLUE )
#endif
#ifndef HAVE_ATEXIT
# define atexit(func) on_exit(func, 0) /* works for SunOS, at least */
@ -942,28 +967,34 @@ exec_script (const char *script, const char* fname, SANE_Bool use_pipe,
format = SANE_FRAME_RGB;
}
sprintf(env[0], "SCAN_RES=%d", res);
if (putenv(env[0]))
fprintf(stderr, "putenv:failed\n");
sprintf(env[1], "SCAN_WIDTH=%d", parm->pixels_per_line);
if (putenv(env[1]))
fprintf(stderr, "putenv:failed\n");
sprintf(env[2], "SCAN_HEIGHT=%d", parm->lines);
if (putenv(env[2]))
fprintf(stderr, "putenv:failed\n");
sprintf(env[3], "SCAN_FORMAT_ID=%d", (int) parm->format);
if (putenv(env[3]))
fprintf(stderr, "putenv:failed\n");
sprintf(env[4], "SCAN_FORMAT=%s",
sane_strframe(parm->format));
if (putenv(env[4]))
fprintf(stderr, "putenv:failed\n");
sprintf(env[5], "SCAN_DEPTH=%d", parm->depth);
if (putenv(env[5]))
fprintf(stderr, "putenv:failed\n");
sprintf(env[6], "SCAN_PIPE=%d", use_pipe);
if (putenv(env[6]))
fprintf(stderr, "putenv:failed\n");
snprintf (env[0], sizeof(env[0]), "SCAN_RES=%d", res);
if (putenv (env[0]))
fprintf (stderr, "putenv:failed\n");
snprintf (env[1], sizeof(env[1]), "SCAN_WIDTH=%d", parm->pixels_per_line);
if (putenv (env[1]))
fprintf (stderr, "putenv:failed\n");
snprintf (env[2], sizeof(env[2]), "SCAN_HEIGHT=%d", parm->lines);
if (putenv (env[2]))
fprintf (stderr, "putenv:failed\n");
snprintf (env[3], sizeof(env[3]), "SCAN_FORMAT_ID=%d", (int) parm->format);
if (putenv (env[3]))
fprintf (stderr, "putenv:failed\n");
snprintf (env[4], sizeof(env[4]), "SCAN_FORMAT=%s",
sane_strframe (parm->format));
if (putenv (env[4]))
fprintf (stderr, "putenv:failed\n");
snprintf (env[5], sizeof(env[5]), "SCAN_DEPTH=%d", parm->depth);
if (putenv (env[5]))
fprintf (stderr, "putenv:failed\n");
snprintf (env[6], sizeof(env[6]), "SCAN_PIPE=%d", use_pipe);
if (putenv (env[6]))
fprintf (stderr, "putenv:failed\n");
if (use_pipe) {
@ -1125,6 +1156,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
}
break;
#if 0 // Not currently supported by SANE
case SANE_FRAME_TEXT:
case SANE_FRAME_JPEG:
case SANE_FRAME_G31D:
@ -1139,6 +1171,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
}
/* write them out without a header; don't buffer */
break;
#endif
default:
/* Default action for unknown frametypes; write them out