Skip to content

Commit

Permalink
kernel: avoid sprintf to silence compiler warnings
Browse files Browse the repository at this point in the history
Latest Apple clang complains about sprintf being used; avoid it. Note
that there are still more sprintf calls in the HPC-GAP code.
  • Loading branch information
fingolfin committed Dec 2, 2022
1 parent 5f10956 commit 0fd95dc
Showing 1 changed file with 4 additions and 8 deletions.
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

0 comments on commit 0fd95dc

Please sign in to comment.