Skip to content

Adapt code to handle return of log_fatal#104

Open
ggeier wants to merge 2 commits intomainfrom
soft-fail-mode
Open

Adapt code to handle return of log_fatal#104
ggeier wants to merge 2 commits intomainfrom
soft-fail-mode

Conversation

@ggeier
Copy link
Copy Markdown
Collaborator

@ggeier ggeier commented Mar 10, 2026

to resolve #102

Signed-off-by: Gideon Sebastian Geier <gideon.sebastian.geier@huawei.com>
Signed-off-by: Gideon Sebastian Geier <gideon.sebastian.geier@huawei.com>
Comment thread src/config.c
char *var = getenv("COLDTRACE_PATH");
if (var == NULL) {
log_fatal("Set COLDTRACE_PATH to a valid directory\n");
return 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use proper names for bool

Comment thread src/config.c
Comment on lines +65 to +68
if (path == NULL) {
log_fatal("error: invalid path\n");
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really necessary? seems impossible. I think it's better to just document the assumption that this path is a valid C string

Comment thread src/entries.c
Comment on lines 169 to 172
default:
log_fatal("Unknown entry size");
break;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is now reachable, which looks like it could make /test/checkers/trace_checker.c#L424 coldtrace_writer_close loop forever instead of crashing.

Comment thread src/entries.c
{
if (!is_type_valid(type)) {
log_fatal("Invalid entry type (at %s:%d)", __FILE__, __LINE__);
return 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only works well if this code is never reached. Otherwise the caller will take a 0-sized entry, which increases the impl->offset by 0, and the same memory will be doubly-allocated by multiple entries.

Almost every line so far has issues. I will continue the review after you have checked your MR a little carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustify error handling

2 participants