[LLVMdev] code analysis bug

Bruce Korb bkorb at gnu.org
Sat Sep 5 12:19:07 PDT 2009


In file included from libopts.c:23:
./makeshell.c:138:26: warning: more '%' conversions than data
arguments
"unset OPT_ARG_VAL || :\n%2$s";

This is not correct.  The format below uses the first argument twice and the
second argument once.  The "clang" analysis does not properly recognize
the "1$" and "2$" modifiers.  This is POSIX for a while, intended for I18N,
but perfectly usable for other purposes.  Like generating shell code.

static char const zLoopEnd[] =
"    if [ -n \"${OPT_ARG_VAL}\" ]\n"
"    then\n"
"        eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
"        export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
"    fi\n"
"done\n\n"
"unset OPT_PROCESS || :\n"
"unset OPT_ELEMENT || :\n"
"unset OPT_ARG || :\n"
"unset OPT_ARG_NEEDED || :\n"
"unset OPT_NAME || :\n"
"unset OPT_CODE || :\n"
"unset OPT_ARG_VAL || :\n%2$s";



More information about the llvm-dev mailing list