Skip to content

Commit ef7a110

Browse files
committed
Resync
1 parent acd3359 commit ef7a110

12 files changed

Lines changed: 160 additions & 193 deletions

File tree

encodings/encoding_utf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
185185
sb++;
186186
}
187187

188-
if ((size_t)(sb - sb_org) > d_len-1 /* NUL */)
188+
if ((size_t)(sb - sb_org) > d_len-1)
189189
{
190190
sb = sb_org + d_len-1;
191191
while ((*sb & 0xC0) == 0x80)

file/archive_file_7z.c

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,27 @@ struct sevenzip_context_t
5959
uint32_t parse_index;
6060
uint32_t decompress_index;
6161
uint32_t packIndex;
62-
uint32_t block_index;
62+
uint32_t block_index;
6363
};
6464

65-
static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t size)
65+
static void *sevenzip_stream_alloc_impl(ISzAllocPtr p, size_t len)
6666
{
67-
if (size == 0)
67+
if (len == 0)
6868
return 0;
69-
return malloc(size);
69+
return malloc(len);
7070
}
7171

7272
static void sevenzip_stream_free_impl(ISzAllocPtr p, void *address)
7373
{
74-
(void)p;
75-
7674
if (address)
7775
free(address);
7876
}
7977

80-
static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t size)
78+
static void *sevenzip_stream_alloc_tmp_impl(ISzAllocPtr p, size_t len)
8179
{
82-
(void)p;
83-
if (size == 0)
80+
if (len == 0)
8481
return 0;
85-
return malloc(size);
82+
return malloc(len);
8683
}
8784

8885
static void* sevenzip_stream_new(void)
@@ -140,11 +137,11 @@ static int64_t sevenzip_file_read(
140137
const char *needle, void **buf,
141138
const char *optional_outfile)
142139
{
140+
CSzArEx db;
143141
CFileInStream archiveStream;
144142
CLookToRead2 lookStream;
145143
ISzAlloc allocImp;
146144
ISzAlloc allocTempImp;
147-
CSzArEx db;
148145
uint8_t *output = 0;
149146
int64_t outsize = -1;
150147

@@ -164,18 +161,16 @@ static int64_t sevenzip_file_read(
164161
#if defined(_WIN32) && defined(USE_WINDOWS_FILE) && !defined(LEGACY_WIN32)
165162
if (!string_is_empty(path))
166163
{
167-
wchar_t *pathW = utf8_to_utf16_string_alloc(path);
168-
169-
if (pathW)
164+
wchar_t *path_w = utf8_to_utf16_string_alloc(path);
165+
if (path_w)
170166
{
171167
/* Could not open 7zip archive? */
172-
if (InFile_OpenW(&archiveStream.file, pathW))
168+
if (InFile_OpenW(&archiveStream.file, path_w))
173169
{
174-
free(pathW);
170+
free(path_w);
175171
return -1;
176172
}
177-
178-
free(pathW);
173+
free(path_w);
179174
}
180175
}
181176
#else
@@ -276,7 +271,7 @@ static int64_t sevenzip_file_read(
276271
* copy and free the old one. */
277272
*buf = malloc((size_t)(outsize + 1));
278273
((char*)(*buf))[outsize] = '\0';
279-
memcpy(*buf,output + offset,outsize);
274+
memcpy(*buf, output + offset, outsize);
280275
}
281276
break;
282277
}
@@ -369,18 +364,18 @@ static int sevenzip_parse_file_init(file_archive_transfer_t *state,
369364
#if defined(_WIN32) && defined(USE_WINDOWS_FILE) && !defined(LEGACY_WIN32)
370365
if (!string_is_empty(file))
371366
{
372-
wchar_t *fileW = utf8_to_utf16_string_alloc(file);
367+
wchar_t *file_w = utf8_to_utf16_string_alloc(file);
373368

374-
if (fileW)
369+
if (file_w)
375370
{
376371
/* could not open 7zip archive? */
377-
if (InFile_OpenW(&sevenzip_context->archiveStream.file, fileW))
372+
if (InFile_OpenW(&sevenzip_context->archiveStream.file, file_w))
378373
{
379-
free(fileW);
374+
free(file_w);
380375
goto error;
381376
}
382377

383-
free(fileW);
378+
free(file_w);
384379
}
385380
}
386381
#else
@@ -439,30 +434,25 @@ static int sevenzip_parse_file_iterate_step_internal(
439434
if ( (_len < PATH_MAX_LENGTH)
440435
&& !SzArEx_IsDir(&sevenzip_context->db, sevenzip_context->parse_index))
441436
{
442-
char infile[PATH_MAX_LENGTH];
443437
SRes res = SZ_ERROR_FAIL;
444438
uint16_t *temp = (uint16_t*)malloc(_len * sizeof(uint16_t));
445439

446440
if (!temp)
447441
return -1;
448442

449-
infile[0] = '\0';
450-
451443
SzArEx_GetFileNameUtf16(&sevenzip_context->db, sevenzip_context->parse_index,
452444
temp);
453445

454446
if (temp)
455447
{
456-
res = utf16_to_char_string(temp, infile, sizeof(infile))
448+
res = utf16_to_char_string(temp, s, PATH_MAX_LENGTH)
457449
? SZ_OK : SZ_ERROR_FAIL;
458450
free(temp);
459451
}
460452

461453
if (res != SZ_OK)
462454
return -1;
463455

464-
strlcpy(s, infile, PATH_MAX_LENGTH);
465-
466456
*cmode = 0; /* unused for 7zip */
467457
*checksum = sevenzip_context->db.CRCs.Vals[sevenzip_context->parse_index];
468458
*size = (uint32_t)SzArEx_GetFileSize(&sevenzip_context->db, sevenzip_context->parse_index);

file/archive_file_zlib.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,13 @@ typedef struct
6161
uint8_t *decompressed_data;
6262
} zip_context_t;
6363

64-
static INLINE uint32_t read_le(const uint8_t *data, unsigned size)
64+
static INLINE uint32_t read_le(const uint8_t *data, size_t len)
6565
{
6666
unsigned i;
6767
uint32_t val = 0;
68-
69-
size *= 8;
70-
for (i = 0; i < size; i += 8)
68+
len *= 8;
69+
for (i = 0; i < len; i += 8)
7170
val |= (uint32_t)*data++ << i;
72-
7371
return val;
7472
}
7573

@@ -114,9 +112,7 @@ static bool zlib_stream_decompress_data_to_file_init(
114112
/* seek past most of the local directory header */
115113
#ifdef HAVE_MMAP
116114
if (state->archive_mmap_data)
117-
{
118115
local_header = state->archive_mmap_data + (size_t)cdata + 26;
119-
}
120116
else
121117
#endif
122118
{
@@ -181,13 +177,11 @@ static int zlib_stream_decompress_data_to_file_iterate(
181177
if (zip_context->cmode == ZIP_MODE_STORED)
182178
{
183179
#ifdef HAVE_MMAP
180+
/* Simply copy the data to the output buffer */
184181
if (zip_context->state->archive_mmap_data)
185-
{
186-
/* Simply copy the data to the output buffer */
187182
memcpy(zip_context->decompressed_data,
188183
zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset,
189184
zip_context->usize);
190-
}
191185
else
192186
#endif
193187
{
@@ -204,27 +198,26 @@ static int zlib_stream_decompress_data_to_file_iterate(
204198
}
205199
else if (zip_context->cmode == ZIP_MODE_DEFLATED)
206200
{
207-
int to_read = MIN(zip_context->csize - zip_context->boffset, _READ_CHUNK_SIZE);
208201
uint8_t *dptr;
202+
int to_read = MIN(zip_context->csize - zip_context->boffset, _READ_CHUNK_SIZE);
203+
/* File was uncompressed or decompression finished before */
209204
if (!zip_context->zstream)
210-
{
211-
/* file was uncompressed or decompression finished before */
212205
return 1;
213-
}
214206

215207
#ifdef HAVE_MMAP
216208
if (state->archive_mmap_data)
217209
{
218210
/* Decompress from the mapped file */
219211
dptr = state->archive_mmap_data + (size_t)zip_context->fdoffset + zip_context->boffset;
220-
rd = to_read;
212+
rd = to_read;
221213
}
222214
else
223215
#endif
224216
{
225217
/* Read some compressed data from file to the temp buffer */
226-
filestream_seek(state->archive_file, zip_context->fdoffset + zip_context->boffset,
227-
RETRO_VFS_SEEK_POSITION_START);
218+
filestream_seek(state->archive_file,
219+
zip_context->fdoffset + zip_context->boffset,
220+
RETRO_VFS_SEEK_POSITION_START);
228221
rd = filestream_read(state->archive_file, zip_context->tmpbuf, to_read);
229222
if (rd < 0)
230223
return -1;
@@ -365,7 +358,6 @@ static int64_t zip_file_read(
365358
file_archive_transfer_t state = {0};
366359
decomp_state_t decomp = {0};
367360
struct archive_extract_userdata userdata = {0};
368-
bool returnerr = true;
369361
int ret = 0;
370362

371363
if (needle)
@@ -380,6 +372,7 @@ static int64_t zip_file_read(
380372

381373
do
382374
{
375+
bool returnerr = true;
383376
ret = file_archive_parse_file_iterate(&state, &returnerr, path,
384377
"", zip_file_decompressed, &userdata);
385378
if (!returnerr)
@@ -522,13 +515,13 @@ static int zip_parse_file_iterate_step(void *context,
522515
file_archive_file_cb file_cb)
523516
{
524517
zip_context_t *zip_context = (zip_context_t *)context;
525-
const uint8_t *cdata = NULL;
526-
uint32_t checksum = 0;
527-
uint32_t size = 0;
528-
uint32_t csize = 0;
529-
unsigned cmode = 0;
530-
unsigned payload = 0;
531-
int ret = zip_parse_file_iterate_step_internal(zip_context,
518+
const uint8_t *cdata = NULL;
519+
uint32_t checksum = 0;
520+
uint32_t size = 0;
521+
uint32_t csize = 0;
522+
unsigned cmode = 0;
523+
unsigned payload = 0;
524+
int ret = zip_parse_file_iterate_step_internal(zip_context,
532525
userdata->current_file_path, &cdata, &cmode, &size, &csize, &checksum, &payload);
533526

534527
if (ret != 1)

file/config_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,24 +1168,24 @@ size_t config_get_config_path(config_file_t *conf, char *s, size_t len)
11681168
}
11691169

11701170
bool config_get_array(config_file_t *conf, const char *key,
1171-
char *buf, size_t size)
1171+
char *buf, size_t len)
11721172
{
11731173
const struct config_entry_list *entry = config_get_entry(conf, key);
11741174
if (entry)
1175-
return strlcpy(buf, entry->value, size) < size;
1175+
return strlcpy(buf, entry->value, len) < len;
11761176
return false;
11771177
}
11781178

11791179
bool config_get_path(config_file_t *conf, const char *key,
1180-
char *buf, size_t size)
1180+
char *buf, size_t len)
11811181
{
11821182
#if defined(RARCH_CONSOLE) || !defined(RARCH_INTERNAL)
1183-
return config_get_array(conf, key, buf, size);
1183+
return config_get_array(conf, key, buf, len);
11841184
#else
11851185
const struct config_entry_list *entry = config_get_entry(conf, key);
11861186
if (entry)
11871187
{
1188-
fill_pathname_expand_special(buf, entry->value, size);
1188+
fill_pathname_expand_special(buf, entry->value, len);
11891189
return true;
11901190
}
11911191
return false;

0 commit comments

Comments
 (0)