Skip to content

Commit 80ed32d

Browse files
committed
Resync
1 parent fa1cb8b commit 80ed32d

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

file/archive_file_7z.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static int sevenzip_parse_file_init(file_archive_transfer_t *state,
355355
if (filestream_read(state->archive_file, magic_buf, SEVENZIP_MAGIC_LEN) != SEVENZIP_MAGIC_LEN)
356356
goto error;
357357

358-
if (string_is_not_equal_fast(magic_buf, SEVENZIP_MAGIC, SEVENZIP_MAGIC_LEN))
358+
if (memcmp(magic_buf, SEVENZIP_MAGIC, SEVENZIP_MAGIC_LEN) != 0)
359359
goto error;
360360

361361
sevenzip_context = (struct sevenzip_context_t*)sevenzip_stream_new();

file/file_path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ size_t fill_pathname_abbreviate_special(char *s,
11421142

11431143
if (!PATH_CHAR_IS_SLASH(*in_path))
11441144
{
1145-
strcpy_literal(s, PATH_DEFAULT_SLASH());
1145+
strcpy(s, PATH_DEFAULT_SLASH());
11461146
s++;
11471147
len--;
11481148
}

formats/png/rpng.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,7 @@ bool rpng_start(rpng_t *rpng)
12051205
if (rpng->buff_end - rpng->buff_data < 8)
12061206
return false;
12071207

1208-
if (string_is_not_equal_fast(
1209-
rpng->buff_data, png_magic, sizeof(png_magic)))
1208+
if (memcmp(rpng->buff_data, png_magic, sizeof(png_magic)) != 0)
12101209
return false;
12111210

12121211
rpng->buff_data += 8;

include/string/stdstring.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ RETRO_BEGIN_DECLS
3737

3838
#define STRLEN_CONST(x) ((sizeof((x))-1))
3939

40-
#define strcpy_literal(a, b) strcpy(a, b)
41-
4240
#define string_is_not_equal(a, b) !string_is_equal((a), (b))
4341

44-
#define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0)
45-
#define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0)
46-
4742
#define TOLOWER(c) ((c) | (lr_char_props[(unsigned char)(c)] & 0x20))
4843
#define TOUPPER(c) ((c) & ~(lr_char_props[(unsigned char)(c)] & 0x20))
4944

@@ -83,16 +78,16 @@ static INLINE bool string_starts_with(const char *str, const char *prefix)
8378
return (str && prefix) ? !strncmp(prefix, str, strlen(prefix)) : false;
8479
}
8580

86-
static INLINE bool string_ends_with_size(const char *str, const char *suffix,
87-
size_t str_len, size_t suffix_len)
81+
static INLINE bool string_ends_with_size(const char *s, const char *suffix,
82+
size_t len, size_t suffix_len)
8883
{
89-
return (str_len < suffix_len) ? false :
90-
!memcmp(suffix, str + (str_len - suffix_len), suffix_len);
84+
return (len < suffix_len) ? false :
85+
!memcmp(suffix, s + (len - suffix_len), suffix_len);
9186
}
9287

93-
static INLINE bool string_ends_with(const char *str, const char *suffix)
88+
static INLINE bool string_ends_with(const char *s, const char *suffix)
9489
{
95-
return str && suffix && string_ends_with_size(str, suffix, strlen(str), strlen(suffix));
90+
return s && suffix && string_ends_with_size(s, suffix, strlen(s), strlen(suffix));
9691
}
9792

9893
/**

test/string/test_stdstring.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ END_TEST
161161

162162
START_TEST (test_string_comparison)
163163
{
164-
ck_assert(string_is_not_equal_fast("foo", "bar", 3));
165-
ck_assert(string_is_equal_fast("foo2", "foo2", 4));
166-
ck_assert(!string_is_equal_fast("foo1", "foo2", 4));
167-
ck_assert(string_is_equal_fast("foo1", "foo2", 3));
164+
ck_assert(memcmp("foo", "bar", 3) != 0);
165+
ck_assert(memcmp("foo2", "foo2", 4) == 0);
166+
ck_assert(memcmp("foo1", "foo2", 4) != 0);
167+
ck_assert(memcmp("foo1", "foo2", 3) == 0);
168168
}
169169
END_TEST
170170

0 commit comments

Comments
 (0)