From 0d5afa6d66d6d75346751cf8e7aabc3319914eb6 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 5 Jul 2026 13:53:31 -0400 Subject: [PATCH] skin_parser: Fix build warnings when included in the theme editor skin_buffer_to_offset() call can never return a "negative" pointer (since it just returns the pointer as-is) so don't bother to check. Change-Id: Id86d53abd7ab1fb071ca54421ebe3b5ff2981c02 --- lib/skin_parser/skin_parser.c | 8 ++++++++ lib/skin_parser/skin_parser.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 0da0528858..0c148ba969 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -465,8 +465,10 @@ static struct skin_element* skin_parse_sublines_optional(const char** document, for(i = 0; i < sublines; i++) { children[i] = skin_buffer_to_offset(skin_parse_line_optional(&cursor, conditional)); +#ifdef OFFSETYYPE_OFFSET if (children[i] < 0) return NULL; +#endif skip_whitespace(&cursor); if(*cursor != MULTILINESYM && i != sublines - 1) @@ -755,8 +757,10 @@ static int skin_parse_tag(struct skin_element* element, const char** document) /* Recursively parsing a code argument */ params[i].type = CODE; params[i].data.code = skin_buffer_to_offset(skin_parse_code_as_arg(&cursor)); +#ifdef OFFSETTYPE_OFFSET if(params[i].data.code < 0) return 0; +#endif } else if (tolower(type_code) == 't') { @@ -874,8 +878,10 @@ static int skin_parse_text(struct skin_element* element, const char** document, element->next = skin_buffer_to_offset(NULL); text = skin_alloc_string(length); element->data = skin_buffer_to_offset(text); +#ifdef OFFSETTYPE_OFFSET if (element->data < 0) return 0; +#endif for(dest = 0; dest < length; dest++) { @@ -1026,8 +1032,10 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc cursor++; } children_array[i] = skin_buffer_to_offset(skin_parse_code_as_arg(&cursor)); +#ifdef OFFSETTYPE_OFFSET if (children_array[i] < 0) return 0; +#endif skip_whitespace(&cursor); #ifdef ROCKBOX if ((element->tag->flags&FEATURE_TAG) && feature_available) diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h index 095c3021e2..e671754e89 100644 --- a/lib/skin_parser/skin_parser.h +++ b/lib/skin_parser/skin_parser.h @@ -52,6 +52,7 @@ typedef long skinoffset_t; * do what you expect. */ #define OFFSETTYPE(type) skinoffset_t +#define OFFSETTYPE_OFFSET #else #define SKINOFFSETTOPTR(base, offset) offset #define PTRTOSKINOFFSET(base, pointer) pointer