From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1161449290886821660==" MIME-Version: 1.0 From: Nick Desaulniers To: kbuild-all@lists.01.org Subject: Re: [zanussi-trace:ftrace/synth-event-gen-v2 10/12] kernel/trace/trace_kprobe.c:974:17: warning: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior Date: Mon, 13 Jan 2020 09:20:07 -0800 Message-ID: In-Reply-To: <202001112058.4xALCb72%lkp@intel.com> List-Id: --===============1161449290886821660== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Tom, Below is a report from a 0day bot build w/ Clang, can you please take a look? (Apologies if this has been previously reported). In the past, -Wvarargs warnings are usually related to the last parameter of a va_arg function undergoing implicit promotion (which is explicitly UB, IIRC). On Sat, Jan 11, 2020 at 4:35 AM kbuild test robot wrote: > > CC: kbuild-all(a)lists.01.org > TO: Tom Zanussi > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/zanussi/linux-tra= ce.git ftrace/synth-event-gen-v2 > head: 91ee64186d5894724e276c4e7fad70446d7a02a7 > commit: 5f052546541d6cc5ad00e28aca6376c221db5c7e [10/12] tracing: Add kpr= obe event command generation functions > config: x86_64-defconfig (attached as .config) > compiler: clang version 10.0.0 (git://gitmirror/llvm_project 016bf03ef6fc= d9dce43b0c17971f76323f07a684) > reproduce: > git checkout 5f052546541d6cc5ad00e28aca6376c221db5c7e > # save the attached .config to linux build tree > make ARCH=3Dx86_64 > > If you fix the issue, kindly add following tag > Reported-by: kbuild test robot > > All warnings (new ones prefixed by >>): > > >> kernel/trace/trace_kprobe.c:974:17: warning: passing an object that un= dergoes default argument promotion to 'va_start' has undefined behavior [-W= varargs] > va_start(args, kretprobe); > ^ > kernel/trace/trace_kprobe.c:947:30: note: parameter of type 'bool' (ak= a '_Bool') is declared here > const char *loc, bool kretprobe, ...) > ^ > 1 warning generated. > > vim +/va_start +974 kernel/trace/trace_kprobe.c > > 925 > 926 /** > 927 * __gen_kprobe_cmd - Generate a synthetic event command from arg= list > 928 * @cmd: A pointer to the dynevent_cmd struct representing the ne= w event > 929 * @name: The name of the kprobe event > 930 * @loc: The location of the kprobe event > 931 * @kretprobe: Is this a return probe? > 932 * @args: Variable number of arg (pairs), one pair for each field > 933 * > 934 * NOTE: Users normally won't want to call this function directly= , but > 935 * rather use the gen_kprobe_cmd() wrapper, which automatically a= dds a > 936 * NULL to the end of the arg list. If this function is used > 937 * directly, make suer he last arg in the variable arg list is NU= LL. > 938 * > 939 * Generate a kprobe event command to be executed by > 940 * create_dynevent(). This function can be used to generate the > 941 * complete command or only the first part of it; in the latter c= ase, > 942 * add_probe_fields() can be used to add more fields following th= is. > 943 * > 944 * Return: 0 if successful, error otherwise. > 945 */ > 946 int __gen_kprobe_cmd(struct dynevent_cmd *cmd, const char *name, > 947 const char *loc, bool kretprobe, ...) > 948 { > 949 char buf[MAX_EVENT_NAME_LEN]; > 950 struct dynevent_arg arg; > 951 va_list args; > 952 int ret; > 953 > 954 if (cmd->type !=3D DYNEVENT_TYPE_KPROBE) > 955 return -EINVAL; > 956 > 957 if (kretprobe) > 958 snprintf(buf, MAX_EVENT_NAME_LEN, "r:%s", name); > 959 else > 960 snprintf(buf, MAX_EVENT_NAME_LEN, "p:%s", name); > 961 > 962 dynevent_arg_init(&arg, NULL, 0); > 963 arg.str =3D buf; > 964 ret =3D add_dynevent_arg(cmd, &arg); > 965 if (ret) > 966 return ret; > 967 > 968 dynevent_arg_init(&arg, NULL, 0); > 969 arg.str =3D loc; > 970 ret =3D add_dynevent_arg(cmd, &arg); > 971 if (ret) > 972 return ret; > 973 > > 974 va_start(args, kretprobe); > 975 for (;;) { > 976 const char *field; > 977 > 978 field =3D va_arg(args, const char *); > 979 if (!field) > 980 break; > 981 > 982 if (++cmd->n_fields > MAX_TRACE_ARGS) { > 983 ret =3D -EINVAL; > 984 break; > 985 } > 986 > 987 dynevent_arg_init(&arg, NULL, 0); > 988 arg.str =3D field; > 989 ret =3D add_dynevent_arg(cmd, &arg); > 990 if (ret) > 991 break; > 992 } > 993 va_end(args); > 994 > 995 return ret; > 996 } > 997 EXPORT_SYMBOL_GPL(__gen_kprobe_cmd); > 998 > > --- > 0-DAY kernel test infrastructure Open Source Technology C= enter > https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corp= oration -- = Thanks, ~Nick Desaulniers --===============1161449290886821660==--