From: Carlos Maddela <e7appew@gmail.com>
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 <e7appew@gmail.com>
Bug-Debian: https://bugs.debian.org/748416
Forwarded: no
Last-Update: 2017-12-21
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---
 closure.c     |  2 +-
 menubar.c     |  2 +-
 rs03-create.c | 24 ++++++++++++------------
 rs03-fix.c    |  8 ++++----
 scsi-layer.c  |  4 ++++
 smart-lec.c   | 10 +++++-----
 6 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/closure.c b/closure.c
index d633d53..fa52f09 100644
--- a/closure.c
+++ b/closure.c
@@ -196,7 +196,7 @@ void ReadDotfile()
       /* Get first MAX_LINE_LEN bytes of line, discard the rest */
      
       line[MAX_LINE_LEN-1] = 1;
-      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')
 	  ;
diff --git a/menubar.c b/menubar.c
index 94d462b..ee24ebe 100644
--- a/menubar.c
+++ b/menubar.c
@@ -414,7 +414,7 @@ void set_path(GtkWidget *entry, char *path)
    else
    {  char buf[PATH_MAX + strlen(path) + 2];
 
-      getcwd(buf, PATH_MAX);
+      if(!getcwd(buf, PATH_MAX)) return;
       strcat(buf,"/");
 
       strcat(buf,path);
diff --git a/rs03-create.c b/rs03-create.c
index 71460ef..9c7265d 100644
--- a/rs03-create.c
+++ b/rs03-create.c
@@ -31,9 +31,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
 
 #ifdef HAVE_MMAP
@@ -714,7 +714,7 @@ static void flush_crc(ecc_closure *ec, LargeFile *file_out)
 
    /* Write out the CRC layer */
       
-   verbose("IO: writing CRC layer\n");
+   verbose("%s", "IO: writing CRC layer\n");
    crc_sect = 2048*(ec->encoderChunk+lay->firstCrcPos);
    if(!LargeSeek(file_out, crc_sect))
    {  ec->abortImmediately = TRUE;
@@ -735,7 +735,7 @@ static void flush_parity(ecc_closure *ec, LargeFile *file_out)
 
    /* Write out the created parity. */
 
-   verbose("IO: writing parity...\n");
+   verbose("%s", "IO: writing parity...\n");
    for(k=0; k<lay->nroots; k++)
    {  gint64 idx=0;
 
@@ -752,7 +752,7 @@ static void flush_parity(ecc_closure *ec, LargeFile *file_out)
 	 }
       }
    }
-   verbose("IO: parity written.\n");
+   verbose("%s", "IO: parity written.\n");
 }
 
 static gpointer io_thread(ecc_closure *ec)
@@ -767,7 +767,7 @@ static gpointer io_thread(ecc_closure *ec)
    int parity_available = 0;
    int i;
 
-   verbose("Reader thread initializing\n");
+   verbose("%s", "Reader thread initializing\n");
 
    /*** Allocate local parity buffer aligned at 128bit boundary */
 
@@ -835,7 +835,7 @@ static gpointer io_thread(ecc_closure *ec)
       {  read_next_chunk(ec, chunk);
 	 //	 flush_crc(ec, file_out);  // FIXME
 	 needs_preload = 0;
-	 verbose("IO: first chunk loaded\n");
+	 verbose("%s", "IO: first chunk loaded\n");
 	 continue;
       }
 
@@ -882,7 +882,7 @@ static gpointer io_thread(ecc_closure *ec)
       g_mutex_lock(ec->lock);
       cpu_bound = ec->buffersToEncode;
       while(ec->buffersToEncode)
-      {  verbose("IO: Waiting for encoders to finish\n");
+      {  verbose("%s", "IO: Waiting for encoders to finish\n");
 	 g_cond_wait(ec->ioCond, ec->lock);
       }
       g_mutex_unlock(ec->lock);
@@ -924,7 +924,7 @@ static gpointer io_thread(ecc_closure *ec)
    ec->slicesFree = TRUE;  /* we have saved the slices; go ahead */
    g_cond_broadcast(ec->ioCond);
    while(ec->buffersToEncode)
-   {  verbose("IO: Waiting for encoders to finish last chunk\n");
+   {  verbose("%s", "IO: Waiting for encoders to finish last chunk\n");
       g_cond_wait(ec->ioCond, ec->lock);
    }
    g_mutex_unlock(ec->lock);
@@ -937,7 +937,7 @@ static gpointer io_thread(ecc_closure *ec)
    flush_crc(ec, file_out);
    flush_parity(ec, file_out);
 
-   verbose("IO: finished\n"); fflush(stdout);
+   verbose("%s", "IO: finished\n"); fflush(stdout);
    return NULL;
 }
 
@@ -1123,7 +1123,7 @@ static gpointer encoder_thread(ecc_closure *ec)
       ec->buffersToEncode-=enc_size;
       if(!ec->buffersToEncode)
       {  g_cond_broadcast(ec->ioCond);
-	 verbose("ENC: processed last buffer; telling IO process.\n");
+	 verbose("%s", "ENC: processed last buffer; telling IO process.\n");
 	 fflush(stdout);
       }
       g_mutex_unlock(ec->lock);
@@ -1223,7 +1223,7 @@ static void create_reed_solomon(ecc_closure *ec)
       verbose("SCHED: joined with worker %d\n", i);
       fflush(stdout);
    }
-   verbose("SCHED: scheduler finished.\n");
+   verbose("%s", "SCHED: scheduler finished.\n");
 }
 
 /***
diff --git a/rs03-fix.c b/rs03-fix.c
index 7afb6d6..19b9322 100644
--- a/rs03-fix.c
+++ b/rs03-fix.c
@@ -829,10 +829,10 @@ void RS03Fix(Image *image)
 	      if we were processing an augmented image. */
 
 	   if(lay->target == ECC_FILE && i >= ndata-1)
-	   {  
-              if(!LargeSeek(image->eccFile, (gint64)(2048*sec)))
-		 Stop(_("Failed seeking to sector %lld in ecc file [%s]: %s"),
-		      sec, "FW", strerror(errno));
+	   {
+		 if(!LargeSeek(image->eccFile, (gint64)(2048*sec)))
+		    Stop(_("Failed seeking to sector %lld in ecc file [%s]: %s"),
+			 sec, "FW", strerror(errno));
 
 	      n = LargeWrite(image->eccFile, cache_offset+fc->imgBlock[i], 2048);
 	      if(n != 2048)
diff --git a/scsi-layer.c b/scsi-layer.c
index b3a9d0e..f8d2112 100644
--- a/scsi-layer.c
+++ b/scsi-layer.c
@@ -31,7 +31,9 @@
 
 static int query_type(DeviceHandle*, int);
 static gint64 query_size(Image*);
+#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);
@@ -1649,6 +1651,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);
@@ -1709,6 +1712,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 02b9c49..944b70d 100644
--- a/smart-lec.c
+++ b/smart-lec.c
@@ -27,9 +27,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
 
 /***
@@ -432,7 +432,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; i<N_P_VECTORS; i++)
    {  if(shc->pState[i] == 1)
@@ -1354,7 +1354,7 @@ static void swap_p_for_new_improvement(sh_context *shc)
 		  count++;
 
 	    if(count < 2)
-	    {  verbose(" pruned");
+	    {  verbose("%s", " pruned");
 	       goto decrement;
 	    }
 
@@ -1417,7 +1417,7 @@ decrement:
 	    if(index >= n_q) break;
 	    selection[index]=0;
 
-	    verbose("\n");
+	    verbose("%s", "\n");
 	 }
       }
    }
