[PATCH] frontend: silence remaining LP64 and K&R warnings

"Maya R. Odinezenko via Lame-dev" <[email protected]> Tue, 21 Jul 2026 19:14:02 -0400
Newsgroups gmane.comp.audio.mp3.lame
Message-ID <CAFCgL3kQMK9An5pT8GTA8S1-QA3gS=mKzt0pKoARKWT2JahF-Q@mail.gmail.com>
Hello,

More from the warning cleanup on the frontend files. Five LP64
narrowing conversions in parse.c and timestatus.c (same pattern
as the get_audio.c patch), four K&R-style empty-parameter
declarations in console.c and parse.h, and two const-qualifier
mismatches where the BSD termcap library declares its id-string
parameters non-const.

-- >8 --
From 7a33fe147d785d8fc0f2e30ebaf4d347a62b4bab Mon Sep 17 00:00:00 2001
From: Maya <[email protected]>
Date: Tue, 21 Jul 2026 19:11:34 -0400
Subject: [PATCH] frontend: silence remaining LP64 and K&R warnings

On LP64 platforms (macOS, 64-bit Linux) the frontend has implicit
long-to-int and size_t-to-int conversions that Apple Clang flags
under -Wshorten-64-to-32, and several function declarations use the
deprecated K&R empty-parameter style.

Add explicit casts at the five narrowing sites in parse.c and
timestatus.c.  Replace the four empty-parameter declarations in
console.c and the one in parse.h with (void).  Cast away const on
the two termcap id strings in console.c where the BSD termcap
library declares its parameters non-const.

No runtime behavior change.  Verified warning-clean under Apple
Clang 21 with the Xcode default warning set.
---
 frontend/console.c    | 12 ++++++------
 frontend/parse.c      |  8 ++++----
 frontend/parse.h      |  2 +-
 frontend/timestatus.c |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/frontend/console.c b/frontend/console.c
index f3a9c40..1322dcc 100644
--- a/frontend/console.c
+++ b/frontend/console.c
@@ -65,7 +65,7 @@ get_termcap_string(char const* id, char* dest, size_t n)
      *  area so the terminal library returns the string from its own storage
      *  instead, and copy from there under a bound.
      */
-    char const *tp = tgetstr(id, NULL);
+    char const *tp = tgetstr((char *)id, NULL);
     if (tp != NULL && dest != NULL && n > 0) {
         strncpy(dest, tp, n);
         dest[n-1] = '\0';
@@ -75,7 +75,7 @@ get_termcap_string(char const* id, char* dest, size_t n)
 static void
 get_termcap_number(char const* id, int* dest, int low, int high)
 {
-    int const val = tgetnum(id);
+    int const val = tgetnum((char *)id);
     if (low <= val && val <= high) {
         *dest = val;
     }
@@ -275,19 +275,19 @@ report_printf(const char *format, ...)
 }

 void
-console_flush()
+console_flush(void)
 {
     frontend_console_flush(ConsoleIoConsole);
 }

 void
-error_flush()
+error_flush(void)
 {
     frontend_console_flush(ConsoleIoError);
 }

 void
-report_flush()
+report_flush(void)
 {
     frontend_console_flush(ConsoleIoReport);
 }
@@ -316,7 +316,7 @@ console_up(int n_lines)
 }

 int
-console_getwidth()
+console_getwidth(void)
 {
     if (is_console_initialized(&Console_IO))
         return Console_IO.disp_width;
diff --git a/frontend/parse.c b/frontend/parse.c
index 6d902ce..a2eb5a4 100644
--- a/frontend/parse.c
+++ b/frontend/parse.c
@@ -396,7 +396,7 @@ static int getIntValue(char const* token, char
const* arg, int* ptr)
     char *_EndPtr=0;
     long d = strtol(arg, &_EndPtr, 10);
     if (ptr != 0) {
-        *ptr = d;
+        *ptr = (int)d;
     }
     return evaluateArgument(token, arg, _EndPtr);
 }
@@ -1619,7 +1619,7 @@ static int dev_only_without_arg(char const* str,
char const* token, int* argIgno
 static int
 set_path_arg(char const *const src, char *const dst)
 {
-    int const arg_n = strnlen(src, PATH_MAX);
+    int const arg_n = (int)strnlen(src, PATH_MAX);
     if (arg_n >= PATH_MAX) {
         error_printf("input/output file name too long (limit %d): %s\n",
                      PATH_MAX, src);
@@ -2138,7 +2138,7 @@ parse_args_(lame_global_flags * gfp, int argc,
char **argv,
                     nogap_tags = 1;

                 T_ELIF("nogapout")
-                    int const arg_n = strnlen(nextArg, PATH_MAX);
+                    int const arg_n = (int)strnlen(nextArg, PATH_MAX);
                     if (arg_n >= PATH_MAX) {
                         error_printf("%s: %s argument length (%d)
exceeds limit (%d)\n", ProgramName, token, arg_n, PATH_MAX);
                         return -1;
@@ -2148,7 +2148,7 @@ parse_args_(lame_global_flags * gfp, int argc,
char **argv,
                     argUsed = 1;

                 T_ELIF("out-dir")
-                    int const arg_n = strnlen(nextArg, PATH_MAX);
+                    int const arg_n = (int)strnlen(nextArg, PATH_MAX);
                     if (arg_n >= PATH_MAX) {
                         error_printf("%s: %s argument length (%d)
exceeds limit (%d)\n", ProgramName, token, arg_n, PATH_MAX);
                         return -1;
diff --git a/frontend/parse.h b/frontend/parse.h
index 0ecd80d..07568fb 100644
--- a/frontend/parse.h
+++ b/frontend/parse.h
@@ -14,7 +14,7 @@ int     display_bitrates(FILE * const fp);
 int     parse_args(lame_global_flags * gfp, int argc, char **argv,
char *const inPath,
                    char *const outPath, char **nogap_inPath, int *num_nogap);

-void    parse_close();
+void    parse_close(void);

 int     generateOutPath(char const* inPath, char const* outDir, char
const* s_ext, char* outPath);

diff --git a/frontend/timestatus.c b/frontend/timestatus.c
index c68d5b3..b031b42 100644
--- a/frontend/timestatus.c
+++ b/frontend/timestatus.c
@@ -396,7 +396,7 @@ decoder_progress_init(unsigned long n, int framesize)
         /* frames_total is an int; a length that would overflow it leaves the
            total unknown, as the sentinel above does */
         if (frames_total <= ((unsigned int)-1)/2)
-            dp->frames_total = frames_total;
+            dp->frames_total = (int)frames_total;
     }
     return dp;
 }
-- 
2.50.1 (Apple Git-155)