]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use an enum for inherit_result_out.
authorNick Mathewson <nickm@torproject.org>
Wed, 3 Apr 2019 14:57:06 +0000 (10:57 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 4 Apr 2019 16:56:52 +0000 (12:56 -0400)
src/lib/malloc/map_anon.c
src/lib/malloc/map_anon.h

index 3e1c22648d53a67dec9a8728636b868abbce085f..f4fda00bff42547437a5c4d0d0d9c48fa36063d1 100644 (file)
@@ -118,7 +118,7 @@ nodump_mem(void *mem, size_t sz)
  * *<b>inherit_result_out</b>.
  */
 static int
-noinherit_mem(void *mem, size_t sz, unsigned *inherit_result_out)
+noinherit_mem(void *mem, size_t sz, inherit_res_t *inherit_result_out)
 {
 #ifdef FLAG_ZERO
   int r = MINHERIT(mem, sz, FLAG_ZERO);
@@ -163,10 +163,11 @@ noinherit_mem(void *mem, size_t sz, unsigned *inherit_result_out)
  * anonymity that Tor is trying to provide.]
  */
 void *
-tor_mmap_anonymous(size_t sz, unsigned flags, unsigned *inherit_result_out)
+tor_mmap_anonymous(size_t sz, unsigned flags,
+                   inherit_res_t *inherit_result_out)
 {
   void *ptr;
-  unsigned itmp=0;
+  inherit_res_t itmp=0;
   if (inherit_result_out == NULL) {
     inherit_result_out = &itmp;
   }
index f101654eb86f463a59e0d46cb9498d01b5c55ffc..6c02cd6c161f8047ec70e6e9ec6efa08a3533e04 100644 (file)
  */
 #define ANONMAP_NOINHERIT (1u<<1)
 
-/** Possible value for inherit_result_out: the memory will be kept
- * by any child process. */
-#define INHERIT_RES_KEEP 0
-/** Possible value for inherit_result_out: the memory will be dropped in
- * the child process. Attempting to access it will likely cause a segfault. */
-#define INHERIT_RES_DROP 1
-/** Possible value for inherit_result_out: the memory will be cleared in
- * the child process. */
-#define INHERIT_RES_ZERO 2
+typedef enum {
+  /** Possible value for inherit_result_out: the memory will be kept
+   * by any child process. */
+  INHERIT_RES_KEEP=0,
+  /** Possible value for inherit_result_out: the memory will be dropped in the
+   * child process. Attempting to access it will likely cause a segfault. */
+  INHERIT_RES_DROP,
+  /** Possible value for inherit_result_out: the memory will be cleared in
+   * the child process. */
+  INHERIT_RES_ZERO
+} inherit_res_t;
 
 /* Here we define the NOINHERIT_CAN_FAIL macro if and only if
  * it's possible that ANONMAP_NOINHERIT might yield inheritable memory.
@@ -63,7 +65,7 @@
 #endif
 
 void *tor_mmap_anonymous(size_t sz, unsigned flags,
-                         unsigned *inherit_result_out);
+                         inherit_res_t *inherit_result_out);
 void tor_munmap_anonymous(void *mapping, size_t sz);
 
 #endif /* !defined(TOR_MAP_ANON_H) */