Add null check for fgets in BufferQueueCore
When compiling BufferQueueCore for host linux, the following
warning/error occurs:
error: ignoring return value of function declared with
'warn_unused_result' attribute [-Werror,-Wunused-result]
Add a simple null check to avoid this error. This is a no-op in terms of
functionality.
Bug: 156675939
Test: m -j libgui
Change-Id: I460731ebaf0272fd5376f244e65b763da44e14f0
diff --git a/libs/gui/BufferQueueCore.cpp b/libs/gui/BufferQueueCore.cpp
index 8d80833..5023b6b 100644
--- a/libs/gui/BufferQueueCore.cpp
+++ b/libs/gui/BufferQueueCore.cpp
@@ -75,10 +75,12 @@
if (NULL != fp) {
const size_t size = 64;
char proc_name[size];
- fgets(proc_name, size, fp);
+ char* result = fgets(proc_name, size, fp);
fclose(fp);
- name = proc_name;
- return NO_ERROR;
+ if (result != nullptr) {
+ name = proc_name;
+ return NO_ERROR;
+ }
}
return INVALID_OPERATION;
}