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

String cleanups #330

Merged
merged 5 commits into from
Nov 13, 2023
Merged

Conversation

minipli-oss
Copy link
Contributor

Minor cleanups I noticed while reviewing some PRs last week.

The memory behind the source pointer passed to memcpy() is only read,
make the function prototype match that fact.

This allows us to get rid of some casts.

Signed-off-by: Mathias Krause <[email protected]>
Make strdup("") do the right thing -- return a duplicate of an empty
string, not NULL. Only return NULL if we got passed a NULL pointer or
the memory allocation failed.

Signed-off-by: Mathias Krause <[email protected]>
Tweak the implementation of strdup() by making ues of memcpy() for the
actual string copy, as we already determined its length before.

Signed-off-by: Mathias Krause <[email protected]>
Instead of attaching the __noreturn annotation to the definition,
attach it to the declaration of panic() to make callers aware that
this function won't return.

Signed-off-by: Mathias Krause <[email protected]>
Move the duplicated code of panic() and warning() to a common helper
that'll take care about the printk()s. The message type ("PANIC" /
"WARNING") will still be center aligned.

Signed-off-by: Mathias Krause <[email protected]>
@minipli-oss minipli-oss requested a review from a team as a code owner November 13, 2023 15:55
Copy link
Contributor

@sktt sktt left a comment

Choose a reason for hiding this comment

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

Neat! looks good from here!
I guess the never-to-be-handled type > stars case is ok for the lack of better option :)

common/console.c Show resolved Hide resolved
@wipawel wipawel merged commit 8350123 into KernelTestFramework:mainline Nov 13, 2023
7 checks passed
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.

3 participants