From d9cda90ad456ce4cc2f954a4228d85799c3fc7d2 Mon Sep 17 00:00:00 2001 From: Daichi Hirono Date: Tue, 20 Jun 2017 16:18:32 +0900 Subject: [PATCH] Add volatile to temporary variable. FuseBuffer::HandleNotImpl save the value of |request.header.unique| to the temporary variable, clear the buffer which is a union of |request| and |response|, then write back the unique value to response.header.unique. Before the CL, the temporary variable was wrongly removed by the compiler optimization, and response.header.unique was always 0. The CL adds volatile modifier as workaround to prevent the compiler optimization from removing the temporary value. Bug: 62429763 Test: libappfuse_tests Change-Id: Ia853f805633f646f316f585a35c7b018000b6eb3 (cherry picked from commit a6dee5e279de56751238f750d12f8a6237992043) --- libappfuse/FuseBuffer.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libappfuse/FuseBuffer.cc b/libappfuse/FuseBuffer.cc index 1b47e0a35..1eab46cb4 100644 --- a/libappfuse/FuseBuffer.cc +++ b/libappfuse/FuseBuffer.cc @@ -251,7 +251,9 @@ void FuseBuffer::HandleInit() { void FuseBuffer::HandleNotImpl() { LOG(VERBOSE) << "NOTIMPL op=" << request.header.opcode << " uniq=" << request.header.unique << " nid=" << request.header.nodeid; - const uint64_t unique = request.header.unique; + // Add volatile as a workaround for compiler issue which removes the temporary + // variable. + const volatile uint64_t unique = request.header.unique; response.Reset(0, -ENOSYS, unique); }