Use C++17's [[nodiscard]] instead of WARN_UNUSED_RESULT

No functionality change. Also remove some header guards along the way.

Test: m
Change-Id: I1afdcaea95a3dd56f392c4e61d7670f43615792a
diff --git a/server/NetlinkCommands.h b/server/NetlinkCommands.h
index ef1ff48..c07194d 100644
--- a/server/NetlinkCommands.h
+++ b/server/NetlinkCommands.h
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef NETD_SERVER_NETLINK_UTIL_H
-#define NETD_SERVER_NETLINK_UTIL_H
+#pragma once
 
 #include <functional>
 #include <linux/netlink.h>
@@ -23,8 +22,7 @@
 
 #include "NetdConstants.h"
 
-namespace android {
-namespace net {
+namespace android::net {
 
 const sockaddr_nl KERNEL_NLADDR = {AF_NETLINK, 0, 0, 0};
 
@@ -44,41 +42,29 @@
 typedef std::function<bool(nlmsghdr *)> NetlinkDumpFilter;
 
 // Opens an RTNetlink socket and connects it to the kernel.
-WARN_UNUSED_RESULT int openNetlinkSocket(int protocol);
+[[nodiscard]] int openNetlinkSocket(int protocol);
 
 // Receives a netlink ACK. Returns 0 if the command succeeded or negative errno if the command
 // failed or receiving the ACK failed.
-WARN_UNUSED_RESULT int recvNetlinkAck(int sock);
+[[nodiscard]] int recvNetlinkAck(int sock);
 
 // Sends a netlink request and possibly expects an ACK. The first element of iov should be null and
 // will be set to the netlink message headerheader. The subsequent elements are the contents of the
 // request.
-
-// Disable optimizations in ASan build.
-// ASan reports an out-of-bounds 32-bit(!) access in the first loop of the
-// function (over iov[]).
-#ifdef __clang__
-#if __has_feature(address_sanitizer)
-__attribute__((optnone))
-#endif
-#endif
-WARN_UNUSED_RESULT int sendNetlinkRequest(uint16_t action, uint16_t flags, iovec* iov, int iovlen,
-                                          const NetlinkDumpCallback *callback);
+[[nodiscard]] int sendNetlinkRequest(uint16_t action, uint16_t flags, iovec* iov, int iovlen,
+                                     const NetlinkDumpCallback* callback);
 
 // Processes a netlink dump, passing every message to the specified |callback|.
-WARN_UNUSED_RESULT int processNetlinkDump(int sock, const NetlinkDumpCallback& callback);
+[[nodiscard]] int processNetlinkDump(int sock, const NetlinkDumpCallback& callback);
 
 // Flushes netlink objects that take an rtmsg structure (FIB rules, routes...). |getAction| and
 // |deleteAction| specify the netlink message types, e.g., RTM_GETRULE and RTM_DELRULE.
 // |shouldDelete| specifies whether a given object should be deleted or not. |what| is a
 // human-readable name for the objects being flushed, e.g. "rules".
-WARN_UNUSED_RESULT int rtNetlinkFlush(uint16_t getAction, uint16_t deleteAction,
-                                      const char *what, const NetlinkDumpFilter& shouldDelete);
+[[nodiscard]] int rtNetlinkFlush(uint16_t getAction, uint16_t deleteAction, const char* what,
+                                 const NetlinkDumpFilter& shouldDelete);
 
 // Returns the value of the specific __u32 attribute, or 0 if the attribute was not present.
 uint32_t getRtmU32Attribute(const nlmsghdr *nlh, int attribute);
 
-}  // namespace net
-}  // namespace android
-
-#endif  // NETD_SERVER_NETLINK_UTIL_H
+}  // namespace android::net