From aa1ce11a67609fdcc466ef6a6adf3bb5027a2df9 Mon Sep 17 00:00:00 2001
From: Sean McBride <sean@rogue-research.com>
Date: Thu, 23 Sep 2021 13:38:25 -0400
Subject: [PATCH] Fixed various -Wshorten-64-to-32 warnings

---
 tools/kiss_fastfir.c | 7 ++++---
 tools/psdpng.c       | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/kiss_fastfir.c b/tools/kiss_fastfir.c
index 02769ff..a117865 100644
--- a/tools/kiss_fastfir.c
+++ b/tools/kiss_fastfir.c
@@ -67,7 +67,7 @@ kiss_fastfir_cfg kiss_fastfir_alloc(
     size_t i;
     size_t nfft=0;
     float scale;
-    int n_freq_bins;
+    size_t n_freq_bins;
     if (pnfft)
         nfft=*pnfft;
 
@@ -346,7 +346,7 @@ void do_file_filter(
 
     kiss_fastfir_cfg cfg;
     kffsamp_t *inbuf,*outbuf;
-    int nread,nwrite;
+    size_t nread,nwrite;
     size_t idx_inbuf;
 
     fdout = fileno(fout);
@@ -374,7 +374,8 @@ void do_file_filter(
         nwrite = kiss_fastfir(cfg, inbuf, outbuf,nread,&idx_inbuf) * sizeof(kffsamp_t);
         /* kiss_fastfir moved any unused samples to the front of inbuf and updated idx_inbuf */
 
-        if ( write(fdout, outbuf, nwrite) != nwrite ) {
+        ssize_t written = write(fdout, outbuf, nwrite);
+        if ( written < 0 || (size_t)written != nwrite ) {
             perror("short write");
             exit(1);
         }
diff --git a/tools/psdpng.c b/tools/psdpng.c
index 9899be4..2e05728 100644
--- a/tools/psdpng.c
+++ b/tools/psdpng.c
@@ -121,7 +121,7 @@ void transform_signal(void)
     kiss_fft_cpx *fbuf;
     float *mag2buf;
     int i;
-    int n;
+    size_t n;
     int avgctr=0;
 
     int nfreqs=nfft/2+1;