summaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2015-09-24 17:07:05 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2015-09-25 10:18:18 -0700
commit3ec832c4b563f3dd1f23399c3bdede1168cc77e7 (patch)
tree95d0e39cedbd092459e030bfaa96b2cc2109f38e /editor.c
parentreplace trivial malloc + sprintf / strcpy calls with xstrfmt (diff)
downloadtgif-3ec832c4b563f3dd1f23399c3bdede1168cc77e7.tar.xz
config: use xstrfmt in normalize_value
We xmalloc a fixed-size buffer and sprintf into it; this is OK because the size of our formatting types is finite, but that's not immediately clear to a reader auditing sprintf calls. Let's switch to xstrfmt, which is shorter and obviously correct. Note that just dropping the common xmalloc here causes gcc to complain with -Wmaybe-uninitialized. That's because if "types" does not match any of our known types, we never write anything into the "normalized" pointer. With the current code, gcc doesn't notice because we always return a valid pointer (just one which might point to uninitialized data, but the compiler doesn't know that). In other words, the current code is potentially buggy if new types are added without updating this spot. So let's take this opportunity to clean up the function a bit more. We can drop the "normalized" pointer entirely, and just return directly from each code path. And then add an assertion at the end in case we haven't covered any cases. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'editor.c')
0 files changed, 0 insertions, 0 deletions