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

kernel: avoid sprintf to silence compiler warnings #5215

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/opers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2904,14 +2904,10 @@ static Obj NewGlobalFunction(Obj name, Obj nams)

// We set the location to a description, to make clear the function
// hasn't been defined yet
const char label[] = "the global function \"%s\" is not yet defined";

// As the '%s' in 'label' will be replaced with 'namobj', there is
// no need for an extra character to store the end-of-string null.
Obj filename = NEW_STRING(strlen(label) + GET_LEN_STRING(namobj));
char * buf = CSTR_STRING(filename);
Int len = sprintf(buf, label, CONST_CSTR_STRING(namobj));
SET_LEN_STRING(filename, len);
Obj filename = MakeString("the global function \"");
AppendString(filename, namobj);
const char * end = "\" is not yet defined";
AppendCStr(filename, end, strlen(end));

Obj body_bag = NewFunctionBody();
SET_FILENAME_BODY(body_bag, filename);
Expand Down