From: Carlos Maddela Date: Thu, 22 Dec 2016 11:19:20 +1100 Subject: Fix all warnings except for those related to deprecated API. Description: Fix all warnings except for those related to deprecated API. Author: Carlos Maddela Origin: vendor Bug-Debian: https://bugs.debian.org/748416 Forwarded: no Last-Update: 2016-12-22 --- This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ --- closure.c | 10 ++++++---- crcbuf.c | 2 -- curve.c | 2 +- debug.c | 2 -- file.c | 6 +++--- heuristic-lec.c | 4 ++++ large-io.c | 4 ++-- md5.c | 2 +- memtrack.c | 3 +-- menubar.c | 5 ++--- preferences.c | 2 +- raw-editor.c | 9 +++------ recover-raw.c | 2 +- rs01-common.c | 2 -- rs01-fix.c | 4 ---- scsi-layer.c | 4 ++++ smart-lec.c | 10 +++++----- tools/codec.c | 2 ++ tools/decimate.c | 1 + tools/memory.c | 3 +-- tools/pngio.c | 4 ++-- tools/pngpack.c | 1 + 22 files changed, 41 insertions(+), 43 deletions(-) diff --git a/closure.c b/closure.c index 6e344a9..ae98b79 100644 --- a/closure.c +++ b/closure.c @@ -402,12 +402,12 @@ void ReadDotfile() while(TRUE) { int n; char symbol[41]; - char *value, *ignore; + char *value; /* Get first MAX_LINE_LEN bytes of line, discard the rest */ line[MAX_LINE_LEN-1] = 1; - ignore = fgets(line, MAX_LINE_LEN, dotfile); + if(!fgets(line, MAX_LINE_LEN, dotfile)) break; if(!line[MAX_LINE_LEN-1]) /* line longer than buffer */ while(!feof(dotfile) && fgetc(dotfile) != '\n') ; @@ -436,12 +436,14 @@ void ReadDotfile() if(!strcmp(symbol, "last-image")) { g_free(Closure->imageName); if(!strcmp(value, "none")) Closure->imageName = g_strdup(""); - else Closure->imageName = g_strdup(value); continue; + else Closure->imageName = g_strdup(value); + continue; } if(!strcmp(symbol, "last-ecc")) { g_free(Closure->eccName); if(!strcmp(value, "none")) Closure->eccName = g_strdup(""); - else Closure->eccName = g_strdup(value); continue; + else Closure->eccName = g_strdup(value); + continue; } if(!strcmp(symbol, "browser")) { g_free(Closure->browser); Closure->browser = g_strdup(value); continue; } diff --git a/crcbuf.c b/crcbuf.c index 598355a..464953f 100644 --- a/crcbuf.c +++ b/crcbuf.c @@ -83,7 +83,6 @@ CrcBuf *GetCRCFromRS02(void *layv, void *dhv, LargeFile *image) AlignedBuffer *ab = CreateAlignedBuffer(2048); CrcBuf *cb = g_malloc(sizeof(CrcBuf)); gint64 block_idx[256]; - guint32 *buf; gint64 image_sectors,crc_sector; gint64 s,i; int crc_idx, crc_valid = FALSE; @@ -93,7 +92,6 @@ CrcBuf *GetCRCFromRS02(void *layv, void *dhv, LargeFile *image) cb->crcbuf = g_malloc(image_sectors * sizeof(guint32)); cb->size = image_sectors; cb->valid = CreateBitmap0(image_sectors); - buf = cb->crcbuf; /* Initialize ecc block index pointers. The first CRC set (of lay->ndata checksums) relates to diff --git a/curve.c b/curve.c index ca8d8c4..d64c2e2 100644 --- a/curve.c +++ b/curve.c @@ -122,7 +122,7 @@ int CurveLogY(Curve *curve, gdouble y) /* not really a log */ hfact = (gdouble)(curve->bottomLY - curve->topLY); if(y==1) return curve->bottomLY - ((log(2)/log(curve->logMaxY)) * hfact)/2; - return curve->bottomLY - (log(y)/log(curve->logMaxY)) * hfact; + return curve->bottomLY - (log(y)/log(curve->logMaxY)) * hfact; } /*** diff --git a/debug.c b/debug.c index 2045ac6..d93f24c 100644 --- a/debug.c +++ b/debug.c @@ -1152,7 +1152,6 @@ void MergeImages(char *arg, int mode) char *left_path, *right_path; gint64 left_sectors, right_sectors,min_sectors,s; int percent,last_percent = 0; - gint64 left_missing, right_missing, mismatch; char *cpos = NULL; /*** Evaluate arguments */ @@ -1185,7 +1184,6 @@ void MergeImages(char *arg, int mode) /*** Compare them */ - left_missing = right_missing = mismatch = 0; if(left_sectors < right_sectors) min_sectors = left_sectors; else min_sectors = right_sectors; diff --git a/file.c b/file.c index bdc4033..e153bd9 100644 --- a/file.c +++ b/file.c @@ -246,9 +246,9 @@ void UnlinkImage(GtkWidget *label) { if(!Closure->guiMode) PrintLog("\n"); - ModalWarning(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, NULL, - _("Image file %s not deleted: %s\n"), - Closure->imageName, strerror(errno)); + ModalWarning(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, NULL, + _("Image file %s not deleted: %s\n"), + Closure->imageName, strerror(errno)); } } diff --git a/heuristic-lec.c b/heuristic-lec.c index 9508c50..2b10d9c 100644 --- a/heuristic-lec.c +++ b/heuristic-lec.c @@ -1865,6 +1865,8 @@ int AckHeuristic(RawBuffer *rb) printf("AH L-EC: iteration %d\n", iteration); printf(" Q-f/c/e + d: %2d/%2d/%2d + %2d\n", q_failures, q_corrected, q_err, q_decimated); printf(" P-f/c/e + d: %2d/%2d/%2d + %2d\n", p_failures, p_corrected, p_err, p_decimated); +#else + (void) p_decimated; #endif if(p_failures + p_err + q_failures + q_err == 0) break; @@ -2120,6 +2122,8 @@ int BruteForceSearchPlausibleSector(RawBuffer *rb) Verbose("SPS L-EC: iteration %d\n", iteration); Verbose(" Q-f/c/e + d: %2d/%2d/%2d + %2d\n", q_failures, q_corrected, q_err, q_decimated); Verbose(" P-f/c/e + d: %2d/%2d/%2d + %2d\n", p_failures, p_corrected, p_err, p_decimated); +#else + (void) p_decimated; #endif if(p_failures + p_err + q_failures + q_err == 0) break; diff --git a/large-io.c b/large-io.c index 04e145f..e2f05e0 100644 --- a/large-io.c +++ b/large-io.c @@ -425,7 +425,7 @@ ssize_t LargeRead(LargeFile *lf, void *buf, size_t count) chunk = count > MAX_FILE_SIZE ? MAX_FILE_SIZE : count; - read_in = read(lf->fileSegment[lf->segment], buf+n, chunk); + read_in = read(lf->fileSegment[lf->segment], (char *)buf+n, chunk); n += read_in; count -= read_in; if(read_in != chunk) return n; @@ -591,7 +591,7 @@ ssize_t LargeWrite(LargeFile *lf, void *buf, size_t count) chunk = count > MAX_FILE_SIZE ? MAX_FILE_SIZE : count; - written = xwrite(lf->fileSegment[lf->segment], buf+n, chunk); + written = xwrite(lf->fileSegment[lf->segment], (char *)buf+n, chunk); n += written; count -= written; if(written != chunk) return n; diff --git a/md5.c b/md5.c index 20c6240..d4e7ca6 100644 --- a/md5.c +++ b/md5.c @@ -159,7 +159,7 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx) MD5Transform(ctx->buf, (guint32 *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memmove(digest, ctx->buf, 16); - memset(ctx, 0, sizeof (ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof (*ctx)); /* In case it's sensitive */ } /* The four core functions - F1 is optimized somewhat */ diff --git a/memtrack.c b/memtrack.c index 68690f3..5f7ac50 100644 --- a/memtrack.c +++ b/memtrack.c @@ -147,9 +147,8 @@ int forget(void *ptr) static void print_ptr(memchunk *mc, int size) { char strbuf[16]; char *ptr = (char*)mc->ptr; - int j,maxlen; + int j; - if(mc->size < size) maxlen = mc->size; else maxlen = size; for(j=0; j<15; j++) { if(ptr[j]<32) break; strbuf[j] = ptr[j]; diff --git a/menubar.c b/menubar.c index f31ae92..99ae4fc 100644 --- a/menubar.c +++ b/menubar.c @@ -396,7 +396,7 @@ static void file_select_cb(GtkWidget *widget, gpointer data) */ void set_path(GtkWidget *entry, char *path) -{ char *ignore; +{ if(path[0] == '/' || path[0] == '\\' || path[1] == ':' || strlen(path) < 1) { gtk_entry_set_text(GTK_ENTRY(entry), path); @@ -405,11 +405,10 @@ void set_path(GtkWidget *entry, char *path) else { char buf[PATH_MAX + strlen(path) + 2]; + if(!getcwd(buf, PATH_MAX)) return; #ifdef SYS_MINGW - ignore = getcwd(buf, PATH_MAX); strcat(buf,"\\"); #else - ignore = getcwd(buf, PATH_MAX); strcat(buf,"/"); #endif strcat(buf,path); diff --git a/preferences.c b/preferences.c index 39f2c5f..db009af 100644 --- a/preferences.c +++ b/preferences.c @@ -21,7 +21,7 @@ #include "dvdisaster.h" -extern int CurrentMediumSize(int); /* from scsi-layer.h */ +extern gint64 CurrentMediumSize(int); /* from scsi-layer.h */ /*** *** debugging workaround diff --git a/raw-editor.c b/raw-editor.c index fd07f48..5818e57 100644 --- a/raw-editor.c +++ b/raw-editor.c @@ -456,13 +456,12 @@ static void buffer_io_cb(GtkWidget *widget, gpointer data) case ACTION_FILESEL_LOAD_OK: { LargeFile *file; char *path; - int n; path = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(rec->loadBufSel)); gtk_widget_hide(rec->loadBufSel); file = LargeOpen(path, O_RDONLY, IMG_PERMS); - n = LargeRead(file, rec->rb->recovered, rec->rb->sampleSize); + LargeRead(file, rec->rb->recovered, rec->rb->sampleSize); LargeClose(file); calculate_failures(rec); @@ -477,13 +476,12 @@ static void buffer_io_cb(GtkWidget *widget, gpointer data) case ACTION_FILESEL_SAVE_OK: { LargeFile *file; char *path; - int n; path = (char*)gtk_file_selection_get_filename(GTK_FILE_SELECTION(rec->saveBufSel)); gtk_widget_hide(rec->saveBufSel); file = LargeOpen(path, O_RDWR | O_CREAT, IMG_PERMS); - n = LargeWrite(file, rec->rb->recovered, rec->rb->sampleSize); + LargeWrite(file, rec->rb->recovered, rec->rb->sampleSize); LargeClose(file); SetLabelText(GTK_LABEL(rec->rightLabel), _("Buffer saved to %s."), path); @@ -653,7 +651,7 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat /* Button press event handler */ static gboolean button_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) -{ static int last_action; +{ raw_editor_context *rec = Closure->rawEditorContext; RawBuffer *rb = rec->rb; int mouse_x = event->x; @@ -816,7 +814,6 @@ static gboolean button_cb(GtkWidget *widget, GdkEventButton *event, gpointer dat // undo_remember(rec); - last_action = rec->onClickAction; return TRUE; } diff --git a/recover-raw.c b/recover-raw.c index 892a7c0..4789922 100644 --- a/recover-raw.c +++ b/recover-raw.c @@ -183,7 +183,7 @@ void ResetRawBuffer(RawBuffer *rb) for(i=0; iqParityN[i][0] = rb->qParityN[i][1] = 0; - rb->bestFrame = rb->bestFrame = 0; + rb->bestFrame = 0; rb->bestP1 = rb->bestP2 = N_P_VECTORS; rb->bestQ1 = rb->bestQ2 = N_Q_VECTORS; } diff --git a/rs01-common.c b/rs01-common.c index b8294c2..c6c2927 100644 --- a/rs01-common.c +++ b/rs01-common.c @@ -96,7 +96,6 @@ void RS01ScanImage(Method *method, ImageInfo *ii, EccInfo *ei, int mode) gint64 prev_missing = 0; gint64 prev_crc_errors = 0; int last_percent,current_missing; - int fp_sector = FINGERPRINT_SECTOR; char *msg; /* Extract widget list from method */ @@ -110,7 +109,6 @@ void RS01ScanImage(Method *method, ImageInfo *ii, EccInfo *ei, int mode) { LargeSeek(ei->file, 0); LargeRead(ei->file, &eh, sizeof(EccHeader)); eh_sectors = uchar_to_gint64(eh.sectors); - fp_sector = eh.fpSector; } /* Position behind the ecc file header, diff --git a/rs01-fix.c b/rs01-fix.c index fe7707b..c6e6a5f 100644 --- a/rs01-fix.c +++ b/rs01-fix.c @@ -115,12 +115,10 @@ void RS01Fix(Method *method) EccHeader *eh = NULL; unsigned char parity[256]; int erasure_count,erasure_list[256],erasure_map[256]; - int unexpected_failure; gint64 block_idx[256]; gint64 s,si; int i,j,k,n; gint64 corrected, uncorrected; - gint64 last_corrected, last_uncorrected; gint64 parity_block = 0; int worst_ecc,damaged_ecc,damaged_sec,percent,last_percent = -1; int cache_size,cache_sector,cache_offset = 0; @@ -345,7 +343,6 @@ void RS01Fix(Method *method) /*** Verify ecc information for the medium image. */ corrected = uncorrected = 0; - last_corrected = last_uncorrected = 0; worst_ecc = damaged_ecc = damaged_sec = local_plot_max = 0; for(si=0; siimgBlock[i]+cache_offset, 2048); diff --git a/scsi-layer.c b/scsi-layer.c index cd7795a..0ba0976 100644 --- a/scsi-layer.c +++ b/scsi-layer.c @@ -30,7 +30,9 @@ static int query_type(DeviceHandle*, int); static unsigned int query_size(DeviceHandle*); +#if 0 static int query_copyright(DeviceHandle*); +#endif static int read_dvd_sector(DeviceHandle*, unsigned char*, int, int); static int read_cd_sector(DeviceHandle*, unsigned char*, int, int); @@ -1656,6 +1658,7 @@ reset_mode_page: * Find out whether we are allowed to create an image from the DVD. */ +#if 0 static int query_copyright(DeviceHandle *dh) { Sense sense; AlignedBuffer *ab = CreateAlignedBuffer(2048); @@ -1716,6 +1719,7 @@ static int query_copyright(DeviceHandle *dh) return result; } +#endif /* * See whether a sector lies within the user area. diff --git a/smart-lec.c b/smart-lec.c index 621ef86..3739a44 100644 --- a/smart-lec.c +++ b/smart-lec.c @@ -26,9 +26,9 @@ #define VERBOSE 1 #ifdef VERBOSE - #define verbose(format,args...) printf(format, ## args) + #define verbose(format,...) printf(format, __VA_ARGS__) #else - #define verbose(format,args...) + #define verbose(format,...) #endif /*** @@ -431,7 +431,7 @@ static void update_pq_state(sh_context *shc) static void print_pq_state(sh_context *shc) { int i; - verbose("PQ states: \n"); + verbose("%s", "PQ states: \n"); for(i=0; ipState[i] == 1) @@ -1353,7 +1353,7 @@ static void swap_p_for_new_improvement(sh_context *shc) count++; if(count < 2) - { verbose(" pruned"); + { verbose("%s", " pruned"); goto decrement; } @@ -1416,7 +1416,7 @@ decrement: if(index >= n_q) break; selection[index]=0; - verbose("\n"); + verbose("%s", "\n"); } } } diff --git a/tools/codec.c b/tools/codec.c index 33b85e0..ed7f4cb 100644 --- a/tools/codec.c +++ b/tools/codec.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -520,6 +521,7 @@ void LoadPPK(char *name, Image ***list_out, int *n_out) file_format = load_int(bzfile); /* always zero */ file_format = load_int(bzfile); + (void) file_format; /* read the image list */ diff --git a/tools/decimate.c b/tools/decimate.c index b754ca4..13cbc6a 100644 --- a/tools/decimate.c +++ b/tools/decimate.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "pngio.h" #include "memory.h" diff --git a/tools/memory.c b/tools/memory.c index edf32ec..2fb34ec 100644 --- a/tools/memory.c +++ b/tools/memory.c @@ -144,9 +144,8 @@ int forget(void *ptr) static void print_ptr(memchunk *mc, int size) { char strbuf[16]; char *ptr = (char*)mc->ptr; - int j,maxlen; + int j; - if(mc->size < size) maxlen = mc->size; else maxlen = size; for(j=0; j<15; j++) { if(ptr[j]<32) break; strbuf[j] = ptr[j]; diff --git a/tools/pngio.c b/tools/pngio.c index 6c0f014..68db499 100644 --- a/tools/pngio.c +++ b/tools/pngio.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "pngio.h" @@ -81,8 +82,7 @@ Image *LoadPNG(char *name) /* verify that we've got a png file */ - fread(buf, 1, 8, pi->file); - if(png_sig_cmp(buf, 0, 8)) + if(fread(buf, 1, 8, pi->file) < 8 || png_sig_cmp(buf, 0, 8)) { fclose(pi->file); fprintf(stdout, "%s is not a .png file!\n", name); fflush(stdout); diff --git a/tools/pngpack.c b/tools/pngpack.c index c0d1c76..f882a08 100644 --- a/tools/pngpack.c +++ b/tools/pngpack.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "md5.h" #include "pngio.h"