aboutsummaryrefslogtreecommitdiff
path: root/layers
diff options
context:
space:
mode:
authorChris Forbes <chrisforbes@google.com>2016-04-28 14:27:19 +1200
committerTobin Ehlis <tobine@google.com>2016-04-28 08:26:44 -0600
commit1b65a150ec6a75b9fca5d7dc88c274bbfb60bd44 (patch)
tree7a67117d477a90aeb10e07458df1f24f6a905a41 /layers
parent2c9664ec83161cffa0001f1b90a4a377822a399b (diff)
downloadusermoji-1b65a150ec6a75b9fca5d7dc88c274bbfb60bd44.tar.xz
layers: Fix -Wunused-result warning for vasprintf
In case of allocation failure, glibc's vasprintf doesn't make any guarantees about the ptr -- the return value is the only way to handle this safely. Signed-off-by: Chris Forbes <chrisforbes@google.com>
Diffstat (limited to 'layers')
-rw-r--r--layers/vk_layer_logging.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/layers/vk_layer_logging.h b/layers/vk_layer_logging.h
index 6a3ec01a..424031a4 100644
--- a/layers/vk_layer_logging.h
+++ b/layers/vk_layer_logging.h
@@ -242,9 +242,13 @@ static inline bool log_msg(debug_report_data *debug_data, VkFlags msgFlags, VkDe
va_list argptr;
va_start(argptr, format);
char *str;
- vasprintf(&str, format, argptr);
+ if (-1 == vasprintf(&str, format, argptr)) {
+ /* on failure, glibc vasprintf leaves str undefined */
+ str = nullptr;
+ }
va_end(argptr);
- bool result = debug_report_log_msg(debug_data, msgFlags, objectType, srcObject, location, msgCode, pLayerPrefix, str);
+ bool result = debug_report_log_msg(debug_data, msgFlags, objectType, srcObject, location, msgCode, pLayerPrefix,
+ str ? str : "Allocation failure");
free(str);
return result;
}