V: Dont use vsprintf/sprintf

Created on 16 Mar 2020  路  3Comments  路  Source: vlang/v

V version: V 0.1.25 66adf7a
OS: OpenBSD

What did you do?
gmake

What did you expect to see?

normal build output

What did you see instead?

Screenshot 2020-03-16 at 11 30 01

$ git grep vsprintf
Binary file thirdparty/glfw/msvc/glfw3.lib matches
vlib/builtin/builtin.v:fn C.vsprintf() int
vlib/builtin/builtin.v:        C.vsprintf(charptr(buf), fmt, argptr)
vlib/compiler/main.v:   vsprintf((char *)buf, fmt, argptr);
vlib/compiler/main.v:   vsprintf((char *)g_str_buf, fmt, argptr);
$ git grep sprintf| grep -v vsprintf
Binary file examples/hot_reload/glfw3.dll matches
thirdparty/bignum/bn.c:    sprintf(&str[i], SPRINTF_FORMAT_STR, n->array[j]);
thirdparty/bignum/bn.h:  /* sprintf format string */
thirdparty/cJSON/cJSON.c:    sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
thirdparty/cJSON/cJSON.c:        length = sprintf((char*)number_buffer, "null");
thirdparty/cJSON/cJSON.c:        length = sprintf((char*)number_buffer, "%1.15g", d);
thirdparty/cJSON/cJSON.c:            length = sprintf((char*)number_buffer, "%1.17g", d);
thirdparty/cJSON/cJSON.c:    /* sprintf failed or buffer overrun occurred */
thirdparty/cJSON/cJSON.c:                    sprintf((char*)output_pointer, "u%04x", *input_pointer);
Binary file thirdparty/glfw/glfw3.dll matches
Binary file thirdparty/glfw/msvc/glfw3.lib matches
thirdparty/vschannel/vschannel.c:   int res = wsprintf(service_name, L"%d", port_number);
thirdparty/vschannel/vschannel.c:   sprintf(pbMessage,  req);
vlib/builtin/cfns.v:fn C.sprintf(a ...voidptr) int
vlib/builtin/int.v: C.sprintf((buf), '%p', ptr)
vlib/builtin/int.v: count := C.sprintf((hex), '0x%x', n)
vlib/compiler/live.v:   sprintf(cpath,"./%s", path);
vlib/compiler/live.v:   sprintf(cpath, "./%s", path);
vlib/compiler/live.v:           sprintf(new_so_base, ".tmp.%d.${file_base}", _live_reloads);
vlib/compiler/live.v:           sprintf(new_so_name, "%s.dll", new_so_base);
vlib/compiler/live.v:           sprintf(new_so_name, "%s.so", new_so_base);
vlib/compiler/live.v:           sprintf(compile_cmd, "$vexe $msvc -o %s -solive -shared $file", new_so_base);
vlib/compiler/string_expression.v:                  p.error('unhandled sprintf format "$typ" ')
vlib/compiler/string_expression.v:      // Otherwise do len counting + allocation + sprintf
vlib/strconv/ftoa/f32_f64_to_string_test.v: "1.23e+302", // this test is failed from C sprintf!!
vlib/time/parse.v:  count := C.sprintf(charptr(tmstr), '%s-%02d-%s %s'.str, fields[3].str, mm,
Bug

All 3 comments

@radare this was fixed? can be closed?

My PR fixed this, in theory github should autoclose this issue after merging a PR with a title matching the "Fix #issuenumber".. not sure why it didnt. I didnt chkd again if there are issues after my pr

I will close this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shouji-kazuo picture shouji-kazuo  路  3Comments

jtkirkpatrick picture jtkirkpatrick  路  3Comments

clpo13 picture clpo13  路  3Comments

penguindark picture penguindark  路  3Comments

ArcDrake picture ArcDrake  路  3Comments