Skip to content

Commit eaf9234

Browse files
committed
Fix discards const from pointer target
Since glibc-2.43 and ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers into their input arrays now have definitions as macros that return a pointer to a const-qualified type when the input argument is a pointer to a const-qualified type. char * pointer returns are only being used for comparisons so declare then as const, which matches the input variables. Fixes: ../../../src/share/getopt/getopt.c: In function 'share___getopt_internal': ../../../src/share/getopt/getopt.c:781:18: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 781 | char *temp = my_index (optstring, c); | ^~~~~~~~ ../../../src/flac/utils.c: In function 'flac__utils_get_channel_mask_tag': ../../../src/flac/utils.c:485:20: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 485 | if(0 == (p = strchr((const char *)object->data.vorbis_comment.comments[offset].entry, '='))) /* should never happen, but just in case */ | ^ ../../../src/flac/main.c: In function 'parse_option': ../../../src/flac/main.c:1137:43: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 1137 | p = strchr(option_argument, ','); | ^ Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
1 parent afb801b commit eaf9234

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/flac/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ int parse_option(int short_option, const char *long_option, const char *option_a
11321132
case 'r':
11331133
{
11341134
uint32_t i;
1135-
char * p;
1135+
const char * p;
11361136
FLAC__ASSERT(0 != option_argument);
11371137
p = strchr(option_argument, ',');
11381138
if(0 == p) {

src/flac/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ FLAC__bool flac__utils_get_channel_mask_tag(const FLAC__StreamMetadata *object,
475475
{
476476
int offset;
477477
uint32_t val;
478-
char *p;
478+
const char *p;
479479
FLAC__ASSERT(object);
480480
FLAC__ASSERT(object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT);
481481
if(0 > (offset = FLAC__metadata_object_vorbiscomment_find_entry_from(object, /*offset=*/0, CHANNEL_MASK_TAG)))

src/share/getopt/getopt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ share___getopt_internal (
778778

779779
{
780780
char c = *nextchar++;
781-
char *temp = my_index (optstring, c);
781+
const char *temp = my_index (optstring, c);
782782

783783
/* Increment `share__optind' when we start to process its last character. */
784784
if (*nextchar == '\0')

0 commit comments

Comments
 (0)