Consolidate various TAKE_* into TAKE_GENERIC(), add TAKE_STRUCT()

This commit is contained in:
Dan Streetman
2023-01-24 18:33:43 +00:00
committed by Luca Boccassi
parent 98a1353014
commit 40c5cc2b21
4 changed files with 17 additions and 30 deletions
+2 -8
View File
@@ -5,13 +5,7 @@
#include "missing_keyctl.h"
/* TAKE_FD but for key_serial_t instead of fds */
#define TAKE_KEY_SERIAL(key_serial) \
({ \
key_serial_t *_key_serialp_ = &(key_serial); \
key_serial_t _key_serial_ = *_key_serialp_; \
*_key_serialp_ = -1; \
_key_serial_; \
})
/* Like TAKE_PTR() but for key_serial_t, resetting them to -1 */
#define TAKE_KEY_SERIAL(key_serial) TAKE_GENERIC(key_serial, key_serial_t, -1)
int keyring_read(key_serial_t serial, void **ret, size_t *ret_size);