Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -Wformat=2 compiler flag #860

Merged
merged 1 commit into from
Jan 29, 2025
Merged

Add -Wformat=2 compiler flag #860

merged 1 commit into from
Jan 29, 2025

Conversation

saghul
Copy link
Contributor

@saghul saghul commented Jan 28, 2025

No description provided.

@saghul
Copy link
Contributor Author

saghul commented Jan 28, 2025

Let's watch it burn :-)

@chqrlie
Copy link
Collaborator

chqrlie commented Jan 28, 2025

Maybe it is time to reconsider using my printf version where atoms can be formatted using %#o...

@saghul
Copy link
Contributor Author

saghul commented Jan 28, 2025

Maybe it is time to reconsider using my printf version where atoms can be formatted using %#o...

IMHO that sounds overkill, just to tame the compiler. We could silence it with a pragma...

@@ -190,6 +190,8 @@ static void js_set_thread_state(JSRuntime *rt, JSThreadState *ts)
js_std_cmd(/*SetOpaque*/1, rt, ts);
}

#pragma GCC diagnostic push
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we are going to work around the compiler, might as well be straight about it.

}

/* %s is replaced by 'atom'. The macro is used so that gcc can check
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This actually didn't work, it errors in bellart/quickjs if you enable -Wformat=2

@@ -3197,7 +3197,6 @@ JSValue JS_NewSymbol(JSContext *ctx, const char *description, bool is_global)

#define ATOM_GET_STR_BUF_SIZE 64

/* Should only be used for debug. */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's also used to print exception messages.

c |= str->u.str8[i];
}
if (c < 0x80)
return (const char *)str->u.str8;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This return broke the "contract" that the function filled the buffer in. Since this is hardly a hot path, let's be consistent and copy the content to the provided buffer.

@saghul saghul requested a review from bnoordhuis January 28, 2025 15:13
@saghul
Copy link
Contributor Author

saghul commented Jan 29, 2025

@bnoordhuis PTAL! You can see the thought process in the shitty conning log. Worry not I'll squash :-)

@saghul saghul merged commit d162c06 into master Jan 29, 2025
61 checks passed
@saghul saghul deleted the wformat2 branch January 29, 2025 21:43
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.

None yet

3 participants