From 2fa8d6655ac37f9bdeb34420000052d921f4a543 Mon Sep 17 00:00:00 2001 From: Michal Zidek Date: Mon, 15 Apr 2013 16:00:46 +0200 Subject: Rename SAFEALIGN macros. https://fedorahosted.org/sssd/ticket/1772 SAFEALIGN macros have been renamed in this patch to make it easy to pick the right macro when data is copied from byte buffer to a variable or vice versa. The renamed macros are placed in new header file to avoid code duplication (the old ones were defined in two files, one for the client code and one for the rest of sssd). --- src/sss_client/sss_cli.h | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'src/sss_client') diff --git a/src/sss_client/sss_cli.h b/src/sss_client/sss_cli.h index a7d99b43..285a2979 100644 --- a/src/sss_client/sss_cli.h +++ b/src/sss_client/sss_cli.h @@ -32,6 +32,8 @@ #include #include +#include "util/util_safealign.h" + #ifndef HAVE_ERRNO_T #define HAVE_ERRNO_T typedef int errno_t; @@ -526,40 +528,6 @@ int sss_ssh_make_request(enum sss_cli_command cmd, uint8_t **repbuf, size_t *replen, int *errnop); -#ifndef SAFEALIGN_COPY_UINT32 -static inline void -safealign_memcpy(void *dest, const void *src, size_t n, size_t *counter) -{ - memcpy(dest, src, n); - if (counter) { - *counter += n; - } -} - -#define SAFEALIGN_SET_VALUE(dest, value, type, pctr) do { \ - type CV_MACRO_val = (type)(value); \ - safealign_memcpy(dest, &CV_MACRO_val, sizeof(type), pctr); \ -} while(0) - -#ifndef SAFEALIGN_SET_UINT32 -#define SAFEALIGN_SET_UINT32(dest, value, pctr) \ - SAFEALIGN_SET_VALUE(dest, value, uint32_t, pctr) -#endif - -#define SAFEALIGN_COPY_UINT32(dest, src, pctr) \ - safealign_memcpy(dest, src, sizeof(uint32_t), pctr) -#endif - -#ifndef SAFEALIGN_SET_UINT16 -#define SAFEALIGN_SET_UINT16(dest, value, pctr) \ - SAFEALIGN_SET_VALUE(dest, value, uint16_t, pctr) -#endif - -#ifndef SAFEALIGN_COPY_UINT16 -#define SAFEALIGN_COPY_UINT16(dest, src, pctr) \ - safealign_memcpy(dest, src, sizeof(uint16_t), pctr) -#endif - #if 0 /* GETSPNAM Request: -- cgit