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/NetworkController.h b/server/NetworkController.h
index 4a363b3..9c6d48a 100644
--- a/server/NetworkController.h
+++ b/server/NetworkController.h
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef NETD_SERVER_NETWORK_CONTROLLER_H
-#define NETD_SERVER_NETWORK_CONTROLLER_H
+#pragma once
 
 #include <android-base/thread_annotations.h>
 #include <android/multinetwork.h>
@@ -37,8 +36,7 @@
 
 struct android_net_context;
 
-namespace android {
-namespace net {
+namespace android::net {
 
 typedef std::shared_lock<std::shared_mutex> ScopedRLock;
 typedef std::lock_guard<std::shared_mutex> ScopedWLock;
@@ -93,7 +91,7 @@
     NetworkController();
 
     unsigned getDefaultNetwork() const;
-    int setDefaultNetwork(unsigned netId) WARN_UNUSED_RESULT;
+    [[nodiscard]] int setDefaultNetwork(unsigned netId);
 
     // Sets |*netId| to an appropriate NetId to use for DNS for the given user. Call with |*netId|
     // set to a non-NETID_UNSET value if the user already has indicated a preference. Returns the
@@ -105,32 +103,32 @@
     unsigned getNetworkForInterface(const char* interface) const;
     bool isVirtualNetwork(unsigned netId) const;
 
-    int createPhysicalNetwork(unsigned netId, Permission permission) WARN_UNUSED_RESULT;
-    int createPhysicalOemNetwork(Permission permission, unsigned *netId) WARN_UNUSED_RESULT;
-    int createVirtualNetwork(unsigned netId, bool secure) WARN_UNUSED_RESULT;
-    int destroyNetwork(unsigned netId) WARN_UNUSED_RESULT;
+    [[nodiscard]] int createPhysicalNetwork(unsigned netId, Permission permission);
+    [[nodiscard]] int createPhysicalOemNetwork(Permission permission, unsigned* netId);
+    [[nodiscard]] int createVirtualNetwork(unsigned netId, bool secure);
+    [[nodiscard]] int destroyNetwork(unsigned netId);
 
-    int addInterfaceToNetwork(unsigned netId, const char* interface) WARN_UNUSED_RESULT;
-    int removeInterfaceFromNetwork(unsigned netId, const char* interface) WARN_UNUSED_RESULT;
+    [[nodiscard]] int addInterfaceToNetwork(unsigned netId, const char* interface);
+    [[nodiscard]] int removeInterfaceFromNetwork(unsigned netId, const char* interface);
 
     Permission getPermissionForUser(uid_t uid) const;
     void setPermissionForUsers(Permission permission, const std::vector<uid_t>& uids);
     int checkUserNetworkAccess(uid_t uid, unsigned netId) const;
-    int setPermissionForNetworks(Permission permission,
-                                 const std::vector<unsigned>& netIds) WARN_UNUSED_RESULT;
+    [[nodiscard]] int setPermissionForNetworks(Permission permission,
+                                               const std::vector<unsigned>& netIds);
 
-    int addUsersToNetwork(unsigned netId, const UidRanges& uidRanges) WARN_UNUSED_RESULT;
-    int removeUsersFromNetwork(unsigned netId, const UidRanges& uidRanges) WARN_UNUSED_RESULT;
+    [[nodiscard]] int addUsersToNetwork(unsigned netId, const UidRanges& uidRanges);
+    [[nodiscard]] int removeUsersFromNetwork(unsigned netId, const UidRanges& uidRanges);
 
     // |nexthop| can be NULL (to indicate a directly-connected route), "unreachable" (to indicate a
     // route that's blocked), "throw" (to indicate the lack of a match), or a regular IP address.
     //
     // Routes are added to tables determined by the interface, so only |interface| is actually used.
     // |netId| is given only to sanity check that the interface has the correct netId.
-    int addRoute(unsigned netId, const char* interface, const char* destination,
-                 const char* nexthop, bool legacy, uid_t uid) WARN_UNUSED_RESULT;
-    int removeRoute(unsigned netId, const char* interface, const char* destination,
-                    const char* nexthop, bool legacy, uid_t uid) WARN_UNUSED_RESULT;
+    [[nodiscard]] int addRoute(unsigned netId, const char* interface, const char* destination,
+                               const char* nexthop, bool legacy, uid_t uid);
+    [[nodiscard]] int removeRoute(unsigned netId, const char* interface, const char* destination,
+                                  const char* nexthop, bool legacy, uid_t uid);
 
     // Notes that the specified address has appeared on the specified interface.
     void addInterfaceAddress(unsigned ifIndex, const char* address);
@@ -156,11 +154,11 @@
     VirtualNetwork* getVirtualNetworkForUserLocked(uid_t uid) const;
     Permission getPermissionForUserLocked(uid_t uid) const;
     int checkUserNetworkAccessLocked(uid_t uid, unsigned netId) const;
-    int createPhysicalNetworkLocked(unsigned netId, Permission permission) WARN_UNUSED_RESULT;
+    [[nodiscard]] int createPhysicalNetworkLocked(unsigned netId, Permission permission);
 
-    int modifyRoute(unsigned netId, const char* interface, const char* destination,
-                    const char* nexthop, bool add, bool legacy, uid_t uid) WARN_UNUSED_RESULT;
-    int modifyFallthroughLocked(unsigned vpnNetId, bool add) WARN_UNUSED_RESULT;
+    [[nodiscard]] int modifyRoute(unsigned netId, const char* interface, const char* destination,
+                                  const char* nexthop, bool add, bool legacy, uid_t uid);
+    [[nodiscard]] int modifyFallthroughLocked(unsigned vpnNetId, bool add);
     void updateTcpSocketMonitorPolling();
 
     class DelegateImpl;
@@ -189,7 +187,4 @@
 
 };
 
-}  // namespace net
-}  // namespace android
-
-#endif  // NETD_SERVER_NETWORK_CONTROLLER_H
+}  // namespace android::net