From 471a345c7d88ea348d7520b973dba25b967917de Mon Sep 17 00:00:00 2001 From: nyov Date: Sat, 22 Nov 2014 05:44:03 +0000 Subject: [PATCH] shut up some Valgrind use of uninitialized memory reports --- .valgrindrc | 2 ++ lhnet.c | 4 +-- matrixlib.c | 1 + netconn.c | 10 +++--- valgrind_dp.supp | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ view.c | 6 ++-- 6 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 .valgrindrc create mode 100644 valgrind_dp.supp diff --git a/.valgrindrc b/.valgrindrc new file mode 100644 index 00000000..9f77fc6f --- /dev/null +++ b/.valgrindrc @@ -0,0 +1,2 @@ +# $ valgrind [valgrind opts] darkplaces [dp args] +--suppressions=valgrind_dp.supp diff --git a/lhnet.c b/lhnet.c index e3bc6b71..132441c4 100644 --- a/lhnet.c +++ b/lhnet.c @@ -156,7 +156,7 @@ int LHNETADDRESS_FromPort(lhnetaddress_t *vaddress, lhnetaddresstype_t addressty #ifdef SUPPORTIPV6 static int LHNETADDRESS_Resolve(lhnetaddressnative_t *address, const char *name, int port) { - char port_buff [16]; + char port_buff [16] = {0}; struct addrinfo hints; struct addrinfo* addrinf; int err; @@ -201,7 +201,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *vaddress, const char *string, int de int i, port, d1, d2, d3, d4, resolved; size_t namelen; unsigned char *a; - char name[128]; + char name[128] = {0}; #ifdef STANDALONETEST char string2[128]; #endif diff --git a/matrixlib.c b/matrixlib.c index 78c859cf..da46e3cd 100644 --- a/matrixlib.c +++ b/matrixlib.c @@ -717,6 +717,7 @@ void Matrix4x4_CreateScale3 (matrix4x4_t *out, double x, double y, double z) void Matrix4x4_CreateFromQuakeEntity(matrix4x4_t *out, double x, double y, double z, double pitch, double yaw, double roll, double scale) { double angle, sr, sp, sy, cr, cp, cy; + angle = sr = sp = sy = cr = cp = cy = 0; // valgrind if (roll) { diff --git a/netconn.c b/netconn.c index 940bb1a7..11124143 100755 --- a/netconn.c +++ b/netconn.c @@ -1705,7 +1705,7 @@ static void NetConn_ClientParsePacket_ServerList_ParseDPList(lhnetaddress_t *sen Con_Printf("received DarkPlaces %sserver list...\n", isextended ? "extended " : ""); while (length >= 7) { - char ipstring [128]; + char ipstring[128] = {0}; // IPv4 address if (data[0] == '\\') @@ -2324,15 +2324,15 @@ void NetConn_QueryQueueFrame(void) continue; } - serverlist_querysleep = false; - if( entry->querycounter != 0 && entry->querytime > timeouttime ) + serverlist_querysleep = false; + if( entry->querycounter != 0 && entry->querytime > timeouttime ) { continue; } - if( entry->querycounter != (unsigned) net_slist_maxtries.integer ) + if( entry->querycounter != (unsigned) net_slist_maxtries.integer ) { - lhnetaddress_t address; + lhnetaddress_t address = {0}; int socket; LHNETADDRESS_FromString(&address, entry->info.cname, 0); diff --git a/valgrind_dp.supp b/valgrind_dp.supp new file mode 100644 index 00000000..b3bf0eab --- /dev/null +++ b/valgrind_dp.supp @@ -0,0 +1,87 @@ +# valgrind error suppression file for darkplaces +# +# (please expand and generalize -- only where needed) +# how to write these: http://valgrind.org/docs/manual/mc-manual.html#mc-manual.suppfiles + +# suppress (leak) errors in all shared libraries +#{ +# ignore_unversioned_libs_leak +# Memcheck:Leak +# ... +# obj:*/lib*/lib*.so +#} +#{ +# ignore_versioned_libs_leak +# Memcheck:Leak +# ... +# obj:*/lib*/lib*.so.* +#} + +# SDL +# ignore calls to it (or not, there are only a few issues here) +#{ +# sdl_c +# Memcheck:Cond +# obj:/usr/lib/x86_64-linux-gnu/libSDL-1.2.so.0.11.4 +# ... +#} + +# fglrx. IGNORE them all... +# (these read: "ignoring anything that called into or is called by this lib (callbacks") +{ + ignore_fglrx_dri_leak + Memcheck:Leak + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} +{ + ignore_fglrx_dri_1 + Memcheck:Addr1 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} +{ + ignore_fglrx_dri_2 + Memcheck:Addr2 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} +{ + ignore_fglrx_dri_4 + Memcheck:Addr4 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} +{ + ignore_fglrx_dri_8 + Memcheck:Addr8 + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} +{ + ignore_fglrx_dri_o + Memcheck:Overlap + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} +{ + ignore_fglrx_dri_c + Memcheck:Cond + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} +{ + ignore_fglrx_dri_p + Memcheck:Param + ioctl(generic) + ... + obj:/usr/lib/x86_64-linux-gnu/dri/fglrx_dri.so + ... +} diff --git a/view.c b/view.c index ac9c5f21..c17ed305 100644 --- a/view.c +++ b/view.c @@ -470,11 +470,11 @@ static void highpass3_limited(vec3_t value, vec_t fracx, vec_t limitx, vec_t fra void V_CalcRefdefUsing (const matrix4x4_t *entrendermatrix, const vec3_t clviewangles, qboolean teleported, qboolean clonground, qboolean clcmdjump, float clstatsviewheight, qboolean cldead, qboolean clintermission, const vec3_t clvelocity) { float vieworg[3], viewangles[3], smoothtime; - float gunorg[3], gunangles[3]; + float gunorg[3], gunangles[3] = {0}; matrix4x4_t tmpmatrix; - + static float viewheightavg; - float viewheight; + float viewheight; #if 0 // begin of chase camera bounding box size for proper collisions by Alexander Zubov vec3_t camboxmins = {-3, -3, -3}; -- 2.39.2