From bf66e346f08eccfa78c1f44c8f512235bc8b3a14 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Tue, 5 Aug 2025 17:12:29 -0400 Subject: [PATCH] Add `-Wobsolete` to RGBFIX and RGBGFX, and deprecate `rgbfix -O` --- contrib/bash_compl/_rgbfix.bash | 1 + contrib/bash_compl/_rgbgfx.bash | 1 + contrib/zsh_compl/_rgbfix | 1 + contrib/zsh_compl/_rgbgfx | 1 + include/fix/warning.hpp | 1 + include/gfx/warning.hpp | 1 + man/rgbfix.1 | 7 +++---- man/rgbgfx.1 | 2 ++ src/fix/main.cpp | 1 + src/fix/warning.cpp | 1 + src/gfx/warning.cpp | 1 + test/fix/overwrite.flags | 4 ++-- 12 files changed, 16 insertions(+), 6 deletions(-) diff --git a/contrib/bash_compl/_rgbfix.bash b/contrib/bash_compl/_rgbfix.bash index 9b827faf..7defc28d 100755 --- a/contrib/bash_compl/_rgbfix.bash +++ b/contrib/bash_compl/_rgbfix.bash @@ -145,6 +145,7 @@ _rgbfix_completions() { warning) mapfile -t COMPREPLY < <(compgen -W " mbc + obsolete overwrite sgb truncation diff --git a/contrib/bash_compl/_rgbgfx.bash b/contrib/bash_compl/_rgbgfx.bash index 356db7b9..849af995 100755 --- a/contrib/bash_compl/_rgbgfx.bash +++ b/contrib/bash_compl/_rgbgfx.bash @@ -157,6 +157,7 @@ _rgbgfx_completions() { warning) mapfile -t COMPREPLY < <(compgen -W " embedded + obsolete trim-nonempty all everything diff --git a/contrib/zsh_compl/_rgbfix b/contrib/zsh_compl/_rgbfix index 4e490faf..49cb9fb3 100644 --- a/contrib/zsh_compl/_rgbfix +++ b/contrib/zsh_compl/_rgbfix @@ -42,6 +42,7 @@ _rgbfix_warnings() { 'everything:Enable literally everything' 'mbc:Warn about issues with MBC specs' + 'obsolete:Warn when using deprecated features' 'overwrite:Warn when overwriting non-zero bytes' 'sgb:Warn when SGB flag conflicts with old licensee code' 'truncation:Warn when values are truncated to fit' diff --git a/contrib/zsh_compl/_rgbgfx b/contrib/zsh_compl/_rgbgfx index ae9f0cd9..ded06f34 100644 --- a/contrib/zsh_compl/_rgbgfx +++ b/contrib/zsh_compl/_rgbgfx @@ -17,6 +17,7 @@ _rgbgfx_warnings() { 'everything:Enable literally everything' 'embedded:Warn when using embedded PLTE without "-c embedded"' + 'obsolete:Warn when using deprecated features' 'trim-nonempty:Warn when "-x" trims nonempty tiles' ) _describe warning warnings diff --git a/include/fix/warning.hpp b/include/fix/warning.hpp index 458b407c..44392344 100644 --- a/include/fix/warning.hpp +++ b/include/fix/warning.hpp @@ -13,6 +13,7 @@ enum WarningLevel { enum WarningID { WARNING_MBC, // Issues with MBC specs + WARNING_OBSOLETE, // Obsolete/deprecated things WARNING_OVERWRITE, // Overwriting non-zero bytes WARNING_SGB, // SGB flag conflicts with old licensee code WARNING_TRUNCATION, // Truncating values to fit diff --git a/include/gfx/warning.hpp b/include/gfx/warning.hpp index af6476d1..79cfdbe8 100644 --- a/include/gfx/warning.hpp +++ b/include/gfx/warning.hpp @@ -13,6 +13,7 @@ enum WarningLevel { enum WarningID { WARNING_EMBEDDED, // Using an embedded PNG palette without '-c embedded' + WARNING_OBSOLETE, // Obsolete/deprecated things WARNING_TRIM_NONEMPTY, // '-x' trims nonempty tiles NB_PLAIN_WARNINGS, diff --git a/man/rgbfix.1 b/man/rgbfix.1 index dc5c03fc..1945c732 100644 --- a/man/rgbfix.1 +++ b/man/rgbfix.1 @@ -8,7 +8,7 @@ .Nd Game Boy header utility and checksum fixer .Sh SYNOPSIS .Nm -.Op Fl hjOsVvw +.Op Fl hjsVvw .Op Fl C | c .Op Fl \-color Ar when .Op Fl f Ar fix_spec @@ -149,9 +149,6 @@ section below. Set the ROM version .Pq Ad 0x14C to a given value from 0 to 0xFF. -.It Fl O , Fl \-overwrite -Alias for -.Fl Wno-overwrite . .It Fl o Ar out_file , Fl \-output Ar out_file Write the modified ROM image to the given file, or '-' to write to standard output. If not specified, the input files are modified in-place, or written to standard output if read from standard input. @@ -253,6 +250,8 @@ prefix, entries are listed alphabetically. .Bl -tag -width Ds .It Fl Wno-mbc Warn when there are inconsistencies with or caveats about the specified MBC type. +.It Fl Wno-obsolete +Warn when obsolete features are encountered, which have been deprecated and may later be removed. .It Fl Wno-overwrite Warn when overwriting different non-zero bytes in the header. .It Fl Wno-sgb diff --git a/man/rgbgfx.1 b/man/rgbgfx.1 index 6b191362..42ada3f1 100644 --- a/man/rgbgfx.1 +++ b/man/rgbgfx.1 @@ -810,6 +810,8 @@ Warn when a generated palette is sorted according to the input PNG's embedded pa was not provided. This warning is enabled by .Fl Weverything . +.It Fl Wno-obsolete +Warn when obsolete features are encountered, which have been deprecated and may later be removed. .It Fl Wtrim-nonempty Warn when .Fl x diff --git a/src/fix/main.cpp b/src/fix/main.cpp index 9c034405..8f17d6fb 100644 --- a/src/fix/main.cpp +++ b/src/fix/main.cpp @@ -778,6 +778,7 @@ int main(int argc, char *argv[]) { break; case 'O': + warning(WARNING_OBSOLETE, "'-O' is deprecated; use '-Wno-overwrite' instead"); warnings.processWarningFlag("no-overwrite"); break; diff --git a/src/fix/warning.cpp b/src/fix/warning.cpp index 4e7605df..6ffdeb33 100644 --- a/src/fix/warning.cpp +++ b/src/fix/warning.cpp @@ -12,6 +12,7 @@ Diagnostics warnings = { }, .warningFlags = { {"mbc", LEVEL_DEFAULT }, + {"obsolete", LEVEL_DEFAULT }, {"overwrite", LEVEL_DEFAULT }, {"sgb", LEVEL_DEFAULT }, {"truncation", LEVEL_DEFAULT }, diff --git a/src/gfx/warning.cpp b/src/gfx/warning.cpp index 01e4016d..3ae0baf2 100644 --- a/src/gfx/warning.cpp +++ b/src/gfx/warning.cpp @@ -17,6 +17,7 @@ Diagnostics warnings = { }, .warningFlags = { {"embedded", LEVEL_EVERYTHING}, + {"obsolete", LEVEL_DEFAULT }, {"trim-nonempty", LEVEL_ALL }, }, .paramWarnings = {}, diff --git a/test/fix/overwrite.flags b/test/fix/overwrite.flags index 76087aca..fadc88b8 100644 --- a/test/fix/overwrite.flags +++ b/test/fix/overwrite.flags @@ -1,2 +1,2 @@ --O -Cjv -t PM_CRYSTAL -i BYTE -n 0 -k 01 -l 0x33 -m 0x10 -r 3 -p 0 -Checks that the -O flag suppresses "Overwrote a non-zero byte" warnings from the rest +-Wno-overwrite -Cjv -t PM_CRYSTAL -i BYTE -n 0 -k 01 -l 0x33 -m 0x10 -r 3 -p 0 +Checks that the -Wno-overwrite flag suppresses "Overwrote a non-zero byte" warnings from the rest