Fixing uninitialized vars etc found by building with -O2

This commit is contained in:
Laria 2024-08-25 18:16:36 +02:00
parent e7e30a5e7d
commit 3ec6aeb106
5 changed files with 15 additions and 12 deletions

View file

@ -139,6 +139,9 @@ main(int argc, const char *argv[])
(void)argc;
const char **argp = argv+1;
int rv = 1;
FILE *in = NULL;
FILE *out = NULL;
@ -159,8 +162,6 @@ main(int argc, const char *argv[])
goto error_before_ctx;
}
int rv = 1;
if (
(in = openfile(argv[0], name_in, "rb")) == NULL
|| (out = openfile(argv[0], name_out, "wb")) == NULL

View file

@ -896,9 +896,8 @@ unserialize_ilist(
struct apfl_string *filename;
FMT_TRY(unserialize_string(unserializer, &filename));
size_t tmproots;
size_t tmproots = apfl_gc_tmproots_begin(unserializer->gc);
if (filename != NULL) {
tmproots = apfl_gc_tmproots_begin(unserializer->gc);
if (!apfl_gc_tmproot_add(unserializer->gc, GC_OBJECT_FROM(filename, GC_TYPE_STRING))) {
return false;
}

View file

@ -2433,15 +2433,16 @@ apfl_load(apfl_ctx ctx, struct apfl_source_reader reader, apfl_stackidx name)
}
struct apfl_error err;
if (!apfl_compile_whole_file(
bool ok = apfl_compile_whole_file(
&ctx->gc,
parser,
&err,
ilist
)) {
);
apfl_parser_destroy(parser);
apfl_tokenizer_destroy(tokenizer);
if (!ok) {
apfl_drop(ctx, -1);
apfl_parser_destroy(parser);
apfl_tokenizer_destroy(tokenizer);
apfl_raise_error_object(ctx, err);
}
}

View file

@ -312,7 +312,7 @@ iter_match(
size_t i
) {
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer(md);
PCRE2_SIZE offset_unadjusted;
PCRE2_SIZE offset_unadjusted = 0;
if (i > 0) {
offset_unadjusted = ovector[1];

View file

@ -49,9 +49,11 @@ int
apfl_string_view_cmp(struct apfl_string_view a, struct apfl_string_view b)
{
size_t n = a.len > b.len ? b.len : a.len;
int cmp = memcmp(a.bytes, b.bytes, n);
if (cmp != 0) {
return cmp;
if (n != 0) {
int cmp = memcmp(a.bytes, b.bytes, n);
if (cmp != 0) {
return cmp;
}
}
if (a.len == b.len) {
return 0;