Skip to content

Commit 92e7fe4

Browse files
committed
Resync
1 parent 2a5b635 commit 92e7fe4

23 files changed

Lines changed: 647 additions & 782 deletions

audio/resampler/drivers/sinc_resampler.c

Lines changed: 324 additions & 339 deletions
Large diffs are not rendered by default.

compat/compat_snprintf.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,49 +35,43 @@
3535

3636
static int c89_vscprintf_retro__(const char *fmt, va_list pargs)
3737
{
38-
int retval;
38+
int _len;
3939
va_list argcopy;
4040
va_copy(argcopy, pargs);
41-
retval = vsnprintf(NULL, 0, fmt, argcopy);
41+
_len = vsnprintf(NULL, 0, fmt, argcopy);
4242
va_end(argcopy);
43-
return retval;
43+
return _len;
4444
}
4545
#endif
4646

4747
/* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */
4848

4949
int c99_vsnprintf_retro__(char *s, size_t len, const char *fmt, va_list ap)
5050
{
51-
int count = -1;
52-
51+
int _len = -1;
5352
if (len != 0)
5453
{
5554
#if (_MSC_VER <= 1310)
56-
count = _vsnprintf(s, len - 1, fmt, ap);
55+
_len = _vsnprintf(s, len - 1, fmt, ap);
5756
#else
58-
count = _vsnprintf_s(s, len, len - 1, fmt, ap);
57+
_len = _vsnprintf_s(s, len, len - 1, fmt, ap);
5958
#endif
6059
}
61-
62-
if (count == -1)
63-
count = _vscprintf(fmt, ap);
64-
60+
if (_len == -1)
61+
_len = _vscprintf(fmt, ap);
6562
/* there was no room for a NULL, so truncate the last character */
66-
if (count == len && len)
63+
if (_len == len && len)
6764
s[len - 1] = '\0';
68-
69-
return count;
65+
return _len;
7066
}
7167

7268
int c99_snprintf_retro__(char *s, size_t len, const char *fmt, ...)
7369
{
74-
int count;
70+
int _len;
7571
va_list ap;
76-
7772
va_start(ap, fmt);
78-
count = c99_vsnprintf_retro__(s, len, fmt, ap);
73+
_len = c99_vsnprintf_retro__(s, len, fmt, ap);
7974
va_end(ap);
80-
81-
return count;
75+
return _len;
8276
}
8377
#endif

compat/compat_vscprintf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434

3535
int c89_vscprintf_retro__(const char *format, va_list pargs)
3636
{
37-
int retval;
37+
int _len;
3838
va_list argcopy;
3939
va_copy(argcopy, pargs);
40-
retval = vsnprintf(NULL, 0, format, argcopy);
40+
_len = vsnprintf(NULL, 0, format, argcopy);
4141
va_end(argcopy);
42-
return retval;
42+
return _len;
4343
}
4444
#endif

file/archive_file.c

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ bool file_archive_extract_file(
338338
char *s, size_t len)
339339
{
340340
struct archive_extract_userdata userdata;
341-
bool ret = true;
342341
struct string_list *list = string_split(valid_exts, "|");
343342

344343
userdata.archive_path[0] = '\0';
@@ -353,37 +352,22 @@ bool file_archive_extract_file(
353352
userdata.transfer = NULL;
354353
userdata.dec = NULL;
355354

356-
if (!list)
357-
{
358-
ret = false;
359-
goto end;
360-
}
361-
362-
if (!file_archive_walk(archive_path, valid_exts,
363-
file_archive_extract_cb, &userdata))
364-
{
365-
/* Parsing file archive failed. */
366-
ret = false;
367-
goto end;
368-
}
369-
370-
if (!userdata.found_file)
355+
if ( list
356+
&& file_archive_walk(archive_path, valid_exts,
357+
file_archive_extract_cb, &userdata)
358+
&& userdata.found_file
359+
)
371360
{
372-
/* Didn't find any file that matched valid extensions
373-
* for libretro implementation. */
374-
ret = false;
375-
goto end;
361+
if (!string_is_empty(userdata.first_extracted_file_path))
362+
strlcpy(s, userdata.first_extracted_file_path, len);
363+
return true;
376364
}
377365

378-
if (!string_is_empty(userdata.first_extracted_file_path))
379-
strlcpy(s, userdata.first_extracted_file_path, len);
380-
381-
end:
382366
if (userdata.first_extracted_file_path)
383367
free(userdata.first_extracted_file_path);
384368
if (list)
385369
string_list_free(list);
386-
return ret;
370+
return false;
387371
}
388372

389373
/* Warning: 'list' must zero initialised before
@@ -533,26 +517,33 @@ static struct string_list *file_archive_filename_split(const char *path)
533517
{
534518
/* add archive path to list first */
535519
if (!string_list_append_n(list, path, (unsigned)(delim - path), attr))
536-
goto error;
520+
{
521+
string_list_free(list);
522+
return NULL;
523+
}
537524

538525
/* now add the path within the archive */
539526
delim++;
540527

541528
if (*delim)
542529
{
543530
if (!string_list_append(list, delim, attr))
544-
goto error;
531+
{
532+
string_list_free(list);
533+
return NULL;
534+
}
545535
}
546536
}
547537
else
538+
{
548539
if (!string_list_append(list, path, attr))
549-
goto error;
540+
{
541+
string_list_free(list);
542+
return NULL;
543+
}
544+
}
550545

551546
return list;
552-
553-
error:
554-
string_list_free(list);
555-
return NULL;
556547
}
557548

558549
/* Generic compressed file loader.

file/archive_file_zlib.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ static bool zlib_stream_decompress_data_to_file_init(
9999
void *context, file_archive_file_handle_t *handle,
100100
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size)
101101
{
102-
zip_context_t *zip_context = (zip_context_t *)context;
103-
struct file_archive_transfer *state = zip_context->state;
104-
uint8_t local_header_buf[4];
102+
int64_t offsetData;
105103
uint8_t *local_header;
106104
uint32_t offsetNL, offsetEL;
107-
int64_t offsetData;
105+
uint8_t local_header_buf[4];
106+
zip_context_t *zip_context = (zip_context_t *)context;
107+
struct file_archive_transfer *state = zip_context->state;
108108

109109
/* free previous data and stream if left unfinished */
110110
zip_context_free_stream(zip_context, false);
@@ -118,7 +118,10 @@ static bool zlib_stream_decompress_data_to_file_init(
118118
{
119119
filestream_seek(state->archive_file, (int64_t)(size_t)cdata + 26, RETRO_VFS_SEEK_POSITION_START);
120120
if (filestream_read(state->archive_file, local_header_buf, 4) != 4)
121-
goto error;
121+
{
122+
zip_context_free_stream(zip_context, false);
123+
return false;
124+
}
122125
local_header = local_header_buf;
123126
}
124127

@@ -156,34 +159,31 @@ static bool zlib_stream_decompress_data_to_file_init(
156159
{
157160
free(zip_context->zstream);
158161
zip_context->zstream = NULL;
159-
goto error;
162+
zip_context_free_stream(zip_context, false);
163+
return false;
160164
}
161165
}
162166

163167
return true;
164-
165-
error:
166-
zip_context_free_stream(zip_context, false);
167-
return false;
168168
}
169169

170170
static int zlib_stream_decompress_data_to_file_iterate(
171171
void *context, file_archive_file_handle_t *handle)
172172
{
173+
int64_t rd;
173174
zip_context_t *zip_context = (zip_context_t *)context;
174175
struct file_archive_transfer *state = zip_context->state;
175-
int64_t rd;
176176

177177
if (zip_context->cmode == ZIP_MODE_STORED)
178178
{
179-
#ifdef HAVE_MMAP
179+
#ifdef HAVE_MMAP
180180
/* Simply copy the data to the output buffer */
181181
if (zip_context->state->archive_mmap_data)
182182
memcpy(zip_context->decompressed_data,
183-
zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset,
184-
zip_context->usize);
183+
zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset,
184+
zip_context->usize);
185185
else
186-
#endif
186+
#endif
187187
{
188188
/* Read the entire file to memory */
189189
filestream_seek(state->archive_file, zip_context->fdoffset, RETRO_VFS_SEEK_POSITION_START);
@@ -204,15 +204,15 @@ static int zlib_stream_decompress_data_to_file_iterate(
204204
if (!zip_context->zstream)
205205
return 1;
206206

207-
#ifdef HAVE_MMAP
207+
#ifdef HAVE_MMAP
208208
if (state->archive_mmap_data)
209209
{
210210
/* Decompress from the mapped file */
211211
dptr = state->archive_mmap_data + (size_t)zip_context->fdoffset + zip_context->boffset;
212212
rd = to_read;
213213
}
214214
else
215-
#endif
215+
#endif
216216
{
217217
/* Read some compressed data from file to the temp buffer */
218218
filestream_seek(state->archive_file,

file/config_file.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -634,20 +634,21 @@ static bool config_file_parse_line(config_file_t *conf,
634634
if (*line != '=')
635635
{
636636
list->value = NULL;
637-
goto error;
637+
list->key = NULL;
638+
free(key);
639+
return false;
638640
}
639641

640642
line++;
641643

642644
if (!(list->value = config_file_extract_value(line)))
643-
goto error;
645+
{
646+
list->key = NULL;
647+
free(key);
648+
return false;
649+
}
644650

645651
return true;
646-
647-
error:
648-
list->key = NULL;
649-
free(key);
650-
return false;
651652
}
652653

653654
static int config_file_from_string_internal(

file/file_path.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,11 @@ char *path_resolve_realpath(char *s, size_t len, bool resolve_symlinks)
805805
tmp[t++] = '/';
806806

807807
if (string_is_empty(s))
808-
goto end;
808+
{
809+
tmp[t] = '\0';
810+
strlcpy(s, tmp, len);
811+
return s;
812+
}
809813

810814
p = s;
811815
}
@@ -851,10 +855,8 @@ char *path_resolve_realpath(char *s, size_t len, bool resolve_symlinks)
851855
while (p <= next)
852856
tmp[t++] = *p++;
853857
}
854-
}while(next < buf_end);
855-
858+
} while(next < buf_end);
856859

857-
end:
858860
tmp[t] = '\0';
859861
strlcpy(s, tmp, len);
860862
return s;

file/nbio/nbio_stdio.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ static void *nbio_stdio_open(const char * filename, unsigned mode)
113113
if (!f)
114114
return NULL;
115115

116-
handle = (struct nbio_stdio_t*)malloc(sizeof(struct nbio_stdio_t));
116+
handle = (struct nbio_stdio_t*)malloc(sizeof(struct nbio_stdio_t));
117117

118118
if (!handle)
119-
goto error;
119+
{
120+
fclose(f);
121+
return NULL;
122+
}
120123

121-
handle->f = f;
124+
handle->f = f;
122125

123126
switch (mode)
124127
{
@@ -143,20 +146,18 @@ static void *nbio_stdio_open(const char * filename, unsigned mode)
143146
#endif
144147

145148
if (len && !buf)
146-
goto error;
149+
{
150+
free(handle);
151+
fclose(f);
152+
return NULL;
153+
}
147154

148155
handle->data = buf;
149156
handle->len = len;
150157
handle->progress = handle->len;
151158
handle->op = -2;
152159

153160
return handle;
154-
155-
error:
156-
if (handle)
157-
free(handle);
158-
fclose(f);
159-
return NULL;
160161
}
161162

162163
static void nbio_stdio_begin_read(void *data)

0 commit comments

Comments
 (0)