First pass of fixes for warnings.

merge-requests/14/head
Ralph Little 2021-08-19 19:57:08 -07:00
rodzic 0d96bd19fb
commit 34a0ebb0b5
6 zmienionych plików z 71 dodań i 65 usunięć

Wyświetl plik

@ -97,10 +97,11 @@ sanei_debug_msg
(int level, int max_level, const char *be, const char *fmt, va_list ap) (int level, int max_level, const char *be, const char *fmt, va_list ap)
{ {
char *msg; char *msg;
if (max_level >= level) if (max_level >= level)
{ {
if ( 1 == isfdtype(fileno(stderr), S_IFSOCK) ) struct stat statbuf;
if ((0 == fstat (fileno (stderr), &statbuf)) && S_ISSOCK(statbuf.st_mode))
{ {
msg = (char *)malloc (sizeof(char) * (strlen(be) + strlen(fmt) + 4)); msg = (char *)malloc (sizeof(char) * (strlen(be) + strlen(fmt) + 4));
if (msg == NULL) if (msg == NULL)
@ -120,7 +121,7 @@ sanei_debug_msg
fprintf (stderr, "[%s] ", be); fprintf (stderr, "[%s] ", be);
vfprintf (stderr, fmt, ap); vfprintf (stderr, fmt, ap);
} }
} }
} }

Wyświetl plik

@ -163,7 +163,7 @@ sanei_thread_begin( int (*func)(void *args), void* args )
DBG( 1, "_beginthread() failed\n" ); DBG( 1, "_beginthread() failed\n" );
return -1; return -1;
} }
DBG( 2, "_beginthread() created thread %d\n", pid ); DBG( 2, "_beginthread() created thread %d\n", pid );
return pid; return pid;
} }
@ -249,7 +249,7 @@ restore_sigpipe( void )
sigemptyset( &act.sa_mask ); sigemptyset( &act.sa_mask );
act.sa_flags = 0; act.sa_flags = 0;
act.sa_handler = SIG_DFL; act.sa_handler = SIG_DFL;
DBG( 2, "restoring SIGPIPE to SIG_DFL\n" ); DBG( 2, "restoring SIGPIPE to SIG_DFL\n" );
sigaction( SIGPIPE, &act, NULL ); sigaction( SIGPIPE, &act, NULL );
} }
@ -327,7 +327,7 @@ sanei_thread_begin( int (func)(void *args), void* args )
/* run in child context... */ /* run in child context... */
int status = func( args ); int status = func( args );
/* don't use exit() since that would run the atexit() handlers */ /* don't use exit() since that would run the atexit() handlers */
_exit( status ); _exit( status );
} }
@ -375,7 +375,7 @@ sanei_thread_waitpid( int pid, int *status )
DBG(2, "* result = %d (%p)\n", stat, (void*)status ); DBG(2, "* result = %d (%p)\n", stat, (void*)status );
result = pid; result = pid;
} }
/* call detach in any case to make sure that the thread resources /* call detach in any case to make sure that the thread resources
* will be freed, when the thread has terminated * will be freed, when the thread has terminated
*/ */
DBG(2, "* detaching thread(%d)\n", pid ); DBG(2, "* detaching thread(%d)\n", pid );

Wyświetl plik

@ -67,7 +67,7 @@ sanei_w_space (Wire * w, size_t howmuch)
if (w->status != 0) if (w->status != 0)
{ {
DBG (1, "sanei_w_space: wire is in invalid state %d\n", DBG (1, "sanei_w_space: wire is in invalid state %d\n",
w->status); w->status);
return; return;
} }
@ -81,7 +81,7 @@ sanei_w_space (Wire * w, size_t howmuch)
case WIRE_ENCODE: case WIRE_ENCODE:
nbytes = w->buffer.curr - w->buffer.start; nbytes = w->buffer.curr - w->buffer.start;
w->buffer.curr = w->buffer.start; w->buffer.curr = w->buffer.start;
DBG (4, "sanei_w_space: ENCODE: sending %lu bytes\n", DBG (4, "sanei_w_space: ENCODE: sending %lu bytes\n",
(u_long) nbytes); (u_long) nbytes);
while (nbytes > 0) while (nbytes > 0)
{ {
@ -184,7 +184,7 @@ sanei_w_array (Wire * w, SANE_Word * len_ptr, void **v,
else else
DBG (1, "sanei_w_array: FREE: tried to free array but *len_ptr or *v " DBG (1, "sanei_w_array: FREE: tried to free array but *len_ptr or *v "
"was NULL\n"); "was NULL\n");
DBG (4, "sanei_w_array: FREE: done\n"); DBG (4, "sanei_w_array: FREE: done\n");
return; return;
} }
@ -200,14 +200,14 @@ sanei_w_array (Wire * w, SANE_Word * len_ptr, void **v,
return; return;
} }
DBG (4, "sanei_w_array: array has %d elements\n", len); DBG (4, "sanei_w_array: array has %d elements\n", len);
if (w->direction == WIRE_DECODE) if (w->direction == WIRE_DECODE)
{ {
*len_ptr = len; *len_ptr = len;
if (len) if (len)
{ {
if (((unsigned int) len) > MAX_MEM if (((unsigned int) len) > MAX_MEM
|| ((unsigned int) len * element_size) > MAX_MEM || ((unsigned int) len * element_size) > MAX_MEM
|| (w->allocated_memory + len * element_size) > MAX_MEM) || (w->allocated_memory + len * element_size) > MAX_MEM)
{ {
DBG (0, "sanei_w_array: DECODE: maximum amount of allocated memory " DBG (0, "sanei_w_array: DECODE: maximum amount of allocated memory "
@ -579,8 +579,8 @@ flush (Wire * w)
void void
sanei_w_set_dir (Wire * w, WireDirection dir) sanei_w_set_dir (Wire * w, WireDirection dir)
{ {
DBG (3, "sanei_w_set_dir: wire %d, old direction WIRE_%s\n", w->io.fd, DBG (3, "sanei_w_set_dir: wire %d, old direction WIRE_%s\n", w->io.fd,
w->direction == WIRE_ENCODE ? "ENCODE" : w->direction == WIRE_ENCODE ? "ENCODE" :
(w->direction == WIRE_DECODE ? "DECODE" : "FREE")); (w->direction == WIRE_DECODE ? "DECODE" : "FREE"));
if (w->direction == WIRE_DECODE && w->buffer.curr != w->buffer.end) if (w->direction == WIRE_DECODE && w->buffer.curr != w->buffer.end)
DBG (1, "sanei_w_set_dir: WARNING: will delete %lu bytes from buffer\n", DBG (1, "sanei_w_set_dir: WARNING: will delete %lu bytes from buffer\n",
@ -589,8 +589,8 @@ sanei_w_set_dir (Wire * w, WireDirection dir)
w->direction = dir; w->direction = dir;
DBG (4, "sanei_w_set_dir: direction changed\n"); DBG (4, "sanei_w_set_dir: direction changed\n");
flush (w); flush (w);
DBG (3, "sanei_w_set_dir: wire %d, new direction WIRE_%s\n", w->io.fd, DBG (3, "sanei_w_set_dir: wire %d, new direction WIRE_%s\n", w->io.fd,
dir == WIRE_ENCODE ? "ENCODE" : dir == WIRE_ENCODE ? "ENCODE" :
(dir == WIRE_DECODE ? "DECODE" : "FREE")); (dir == WIRE_DECODE ? "DECODE" : "FREE"));
} }
@ -654,13 +654,13 @@ void
sanei_w_init (Wire * w, void (*codec_init_func) (Wire *)) sanei_w_init (Wire * w, void (*codec_init_func) (Wire *))
{ {
DBG_INIT (); DBG_INIT ();
DBG (3, "sanei_w_init: initializing\n"); DBG (3, "sanei_w_init: initializing\n");
w->status = 0; w->status = 0;
w->direction = WIRE_ENCODE; w->direction = WIRE_ENCODE;
w->buffer.size = 8192; w->buffer.size = 8192;
w->buffer.start = malloc (w->buffer.size); w->buffer.start = malloc (w->buffer.size);
if (w->buffer.start == 0) if (w->buffer.start == 0)
{ {
/* Malloc failed, so return an error. */ /* Malloc failed, so return an error. */

Wyświetl plik

@ -114,7 +114,7 @@ progress_update (Progress_t * p, gfloat newval)
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
struct timeval tv; struct timeval tv;
int now; int now;
char buff[40]; char buff[100];
int remaining; int remaining;
#endif #endif
@ -126,6 +126,8 @@ progress_update (Progress_t * p, gfloat newval)
gtk_progress_bar_update (GTK_PROGRESS_BAR (p->pbar), newval); gtk_progress_bar_update (GTK_PROGRESS_BAR (p->pbar), newval);
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
fprintf(stderr, "Hello!!!!!!!\n");
gettimeofday (&tv, NULL); gettimeofday (&tv, NULL);
now = tv.tv_sec * 1000 + tv.tv_usec / 1000; now = tv.tv_sec * 1000 + tv.tv_usec / 1000;
@ -138,6 +140,7 @@ progress_update (Progress_t * p, gfloat newval)
if (newval > p->firstVal && now - p->lastTime > 1000) if (newval > p->firstVal && now - p->lastTime > 1000)
{ {
fprintf(stderr, "Hello2!!!!!!!\n");
remaining = remaining =
(int) ((now - p->firstTime) * (1.0 - newval) / (newval - (int) ((now - p->firstTime) * (1.0 - newval) / (newval -
p->firstVal) / p->firstVal) /

Wyświetl plik

@ -1,6 +1,6 @@
/* saneadf - a SANE front end for document scanning /* saneadf - a SANE front end for document scanning
based on based on
bnhscan by tummy.com and bnhscan by tummy.com and
scanimage by Andreas Beck and David Mosberger scanimage by Andreas Beck and David Mosberger
Copyright (C) 1999 Tom Martone Copyright (C) 1999 Tom Martone
@ -123,7 +123,7 @@ static struct option basic_options[] =
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"verbose", no_argument, NULL, 'v'}, {"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'}, {"version", no_argument, NULL, 'V'},
{"no-overwrite", no_argument, NULL, 'N'}, {"no-overwrite", no_argument, NULL, 'N'},
{ "output-file", required_argument, 0, 'o' }, { "output-file", required_argument, 0, 'o' },
{ "start-count", required_argument, 0, 's' }, { "start-count", required_argument, 0, 's' },
@ -299,9 +299,9 @@ print_option (SANE_Device *device, int opt_num, char short_name)
break; break;
} }
} }
if (opt->type == SANE_TYPE_STRING || if (opt->type == SANE_TYPE_STRING ||
opt->type == SANE_TYPE_BOOL || opt->type == SANE_TYPE_BOOL ||
opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_INT ||
opt->type == SANE_TYPE_FIXED) opt->type == SANE_TYPE_FIXED)
{ {
/* print current option value */ /* print current option value */
@ -913,23 +913,23 @@ get_resolution(SANE_Device *device)
{ {
opt = sane_get_option_descriptor (device, resolution_opt); opt = sane_get_option_descriptor (device, resolution_opt);
sane_control_option (device, resolution_opt, sane_control_option (device, resolution_opt,
SANE_ACTION_GET_VALUE, &val, 0); SANE_ACTION_GET_VALUE, &val, 0);
switch (opt->type) switch (opt->type)
{ {
case SANE_TYPE_INT: case SANE_TYPE_INT:
res = val; res = val;
break; break;
case SANE_TYPE_FIXED: case SANE_TYPE_FIXED:
res = (SANE_Int) SANE_UNFIX(val); res = (SANE_Int) SANE_UNFIX(val);
break; break;
case SANE_TYPE_STRING: case SANE_TYPE_STRING:
case SANE_TYPE_BOOL: case SANE_TYPE_BOOL:
default: default:
if (verbose) if (verbose)
fprintf(stderr, fprintf(stderr,
"Peculiar option data type for resolution, " "Peculiar option data type for resolution, "
"using default value.\n"); "using default value.\n");
break; break;
@ -1002,9 +1002,9 @@ exec_script (const char *script, const char* fname, SANE_Bool use_pipe,
} }
/*signal(SIGCHLD, SIG_IGN);*/ /*signal(SIGCHLD, SIG_IGN);*/
switch ((pid = fork())) switch ((pid = fork()))
{ {
case -1: case -1:
/* fork failed */ /* fork failed */
fprintf(stderr, "Error forking: %s (%d)\n", strerror(errno), errno); fprintf(stderr, "Error forking: %s (%d)\n", strerror(errno), errno);
break; break;
@ -1017,9 +1017,9 @@ exec_script (const char *script, const char* fname, SANE_Bool use_pipe,
sprintf(cmd, "%s '%s'", script, fname); sprintf(cmd, "%s '%s'", script, fname);
execle(script, script, fname, NULL, environ); execle(script, script, fname, NULL, environ);
exit(0); exit(0);
default: default:
if (verbose) if (verbose)
fprintf(stderr, "Started script `%s' as pid=%d\n", script, pid); fprintf(stderr, "Started script `%s' as pid=%d\n", script, pid);
break; break;
} }
@ -1149,7 +1149,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
} }
else else
{ {
write_pnm_header_to_file (fp, parm.format, write_pnm_header_to_file (fp, parm.format,
parm.pixels_per_line, parm.pixels_per_line,
parm.lines, parm.depth); parm.lines, parm.depth);
} }
@ -1174,7 +1174,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
#endif #endif
default: default:
/* Default action for unknown frametypes; write them out /* Default action for unknown frametypes; write them out
* without a header; issue a warning in verbose mode. * without a header; issue a warning in verbose mode.
* Since we're not writing a header, there's no need to * Since we're not writing a header, there's no need to
* buffer. * buffer.
@ -1210,7 +1210,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
else else
image.height = 0; image.height = 0;
image.Bpp = 3; image.Bpp = 3;
if (parm.format == SANE_FRAME_GRAY || if (parm.format == SANE_FRAME_GRAY ||
!sane_isbasicframe(parm.format)) !sane_isbasicframe(parm.format))
image.Bpp = 1; image.Bpp = 1;
image.x = image.width - 1; image.x = image.width - 1;
@ -1226,7 +1226,7 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
offset = parm.format - SANE_FRAME_RED; offset = parm.format - SANE_FRAME_RED;
image.x = image.y = 0; image.x = image.y = 0;
} }
while (1) while (1)
{ {
status = sane_read (device, buffer, sizeof (buffer), &len); status = sane_read (device, buffer, sizeof (buffer), &len);
@ -1309,13 +1309,13 @@ scan_it_raw (const char *fname, SANE_Bool raw, const char *script,
if (raw == SANE_FALSE) if (raw == SANE_FALSE)
{ {
/* if we're writing raw, we skip the header */ /* if we're writing raw, we skip the header */
write_pnm_header_to_file (fp, parm.format, image.width, write_pnm_header_to_file (fp, parm.format, image.width,
image.height, parm.depth); image.height, parm.depth);
} }
fwrite (image.data, image.Bpp, image.height * image.width, fp); fwrite (image.data, image.Bpp, image.height * image.width, fp);
} }
if (fp) if (fp)
{ {
fclose(fp); fclose(fp);
fp = NULL; fp = NULL;
@ -1340,7 +1340,7 @@ cleanup:
return status; return status;
} }
static SANE_Int static SANE_Int
scan_docs (int start, int end, int no_overwrite, SANE_Bool raw, scan_docs (int start, int end, int no_overwrite, SANE_Bool raw,
const char *outfmt, const char *script, SANE_Bool use_pipe) const char *outfmt, const char *script, SANE_Bool use_pipe)
{ {
@ -1350,27 +1350,27 @@ scan_docs (int start, int end, int no_overwrite, SANE_Bool raw,
struct stat statbuf; struct stat statbuf;
int res; int res;
while (end < 0 || start <= end) while (end < 0 || start <= end)
{ {
snprintf(fname, sizeof (fname), outfmt, start); snprintf(fname, sizeof (fname), outfmt, start);
/* does the filename already exist? */ /* does the filename already exist? */
if (no_overwrite) if (no_overwrite)
{ {
res = stat (fname, &statbuf); res = stat (fname, &statbuf);
if (res == 0) if (res == 0)
{ {
status = SANE_STATUS_INVAL; status = SANE_STATUS_INVAL;
fprintf (stderr, "Filename %s already exists; will not overwrite\n", fname); fprintf (stderr, "Filename %s already exists; will not overwrite\n", fname);
} }
} }
/* Scan the document */ /* Scan the document */
if (status == SANE_STATUS_GOOD) if (status == SANE_STATUS_GOOD)
status = scan_it_raw(fname, raw, script, use_pipe); status = scan_it_raw(fname, raw, script, use_pipe);
/* Any scan errors? */ /* Any scan errors? */
if (status == SANE_STATUS_NO_DOCS) if (status == SANE_STATUS_NO_DOCS)
{ {
/* out of paper in the hopper; this is our normal exit */ /* out of paper in the hopper; this is our normal exit */
status = SANE_STATUS_GOOD; status = SANE_STATUS_GOOD;
@ -1384,7 +1384,7 @@ scan_docs (int start, int end, int no_overwrite, SANE_Bool raw,
scannedPages++; scannedPages++;
start++; start++;
} }
else else
{ {
/* unexpected error */ /* unexpected error */
fprintf(stderr, "%s\n", sane_strstatus(status)); fprintf(stderr, "%s\n", sane_strstatus(status));
@ -1715,4 +1715,3 @@ List of available devices:", prog_name);
return (status == SANE_STATUS_GOOD) ? 0 : 1; return (status == SANE_STATUS_GOOD) ? 0 : 1;
} }

Wyświetl plik

@ -1,9 +1,9 @@
/* xcam -- X-based camera frontend /* xcam -- X-based camera frontend
Uses the SANE library. Uses the SANE library.
Copyright (C) 1997 David Mosberger and Tristan Tarrant Copyright (C) 1997 David Mosberger and Tristan Tarrant
Update 2005 Gerard Klaver Update 2005 Gerard Klaver
The add_text routine and font_6x11.h file are taken from the (GPLed) The add_text routine and font_6x11.h file are taken from the (GPLed)
webcam.c file, part of xawtv, (c) 1998-2002 Gerd Knorr. webcam.c file, part of xawtv, (c) 1998-2002 Gerd Knorr.
add_text was modified for this program (xcam_add_text). add_text was modified for this program (xcam_add_text).
Update 2008 Gerard Klaver Update 2008 Gerard Klaver
@ -326,9 +326,9 @@ save_settings (const char *filename)
} }
#define MSG_MAXLEN 45 #define MSG_MAXLEN 45
#define CHAR_HEIGHT 11 #define TEXT_HEIGHT 11
#define CHAR_WIDTH 6 #define TEXT_WIDTH 6
#define CHAR_START 4 #define TEXT_START 4
static SANE_Status static SANE_Status
xcam_add_text (SANE_Byte * image, int width, int height, char *txt) xcam_add_text (SANE_Byte * image, int width, int height, char *txt)
@ -359,16 +359,16 @@ xcam_add_text (SANE_Byte * image, int width, int height, char *txt)
{ {
case SANE_FRAME_RGB: case SANE_FRAME_RGB:
for (y = 0; y < CHAR_HEIGHT; y++) for (y = 0; y < TEXT_HEIGHT; y++)
{ {
ptr = image + 3 * width * (height - CHAR_HEIGHT - 2 + y) + 12; ptr = image + 3 * width * (height - TEXT_HEIGHT - 2 + y) + 12;
for (x = 0; x < len; x++) for (x = 0; x < len; x++)
{ {
f = fontdata[line[x] * CHAR_HEIGHT + y]; f = fontdata[line[x] * TEXT_HEIGHT + y];
for (i = CHAR_WIDTH - 1; i >= 0; i--) for (i = TEXT_WIDTH - 1; i >= 0; i--)
{ {
if (f & (CHAR_START << i)) if (f & (TEXT_START << i))
{ {
ptr[0] = 255; ptr[0] = 255;
ptr[1] = 255; ptr[1] = 255;
@ -381,29 +381,32 @@ xcam_add_text (SANE_Byte * image, int width, int height, char *txt)
break; break;
case SANE_FRAME_GRAY: case SANE_FRAME_GRAY:
for (y = 0; y < CHAR_HEIGHT; y++) for (y = 0; y < TEXT_HEIGHT; y++)
{ {
ptr = image + width * (height - CHAR_HEIGHT - 2 + y) + 12; ptr = image + width * (height - TEXT_HEIGHT - 2 + y) + 12;
for (x = 0; x < len; x++) for (x = 0; x < len; x++)
{ {
f = fontdata[line[x] * CHAR_HEIGHT + y]; f = fontdata[line[x] * TEXT_HEIGHT + y];
for (i = CHAR_WIDTH - 1; i >= 0; i--) for (i = TEXT_WIDTH - 1; i >= 0; i--)
{ {
if (f & (CHAR_START << i)) if (f & (TEXT_START << i))
{ {
ptr[0] = 255; ptr[0] = 255;
} }
ptr += 1; ptr += 1;
} /* for i */ } /* for i */
} /* for x */ } /* for x */
} /* for y */ } /* for y */
break;
case SANE_FRAME_RED: case SANE_FRAME_RED:
case SANE_FRAME_GREEN: case SANE_FRAME_GREEN:
case SANE_FRAME_BLUE: case SANE_FRAME_BLUE:
snprintf (buf, sizeof (buf), snprintf (buf, sizeof (buf),
"Time stamp for separate channel transfers are not supported"); "Time stamp for separate channel transfers are not supported");
break; break;
default: default:
snprintf (buf, sizeof (buf), snprintf (buf, sizeof (buf),
"Unsupported image format %d", win.params.format); "Unsupported image format %d", win.params.format);