pass lint

This commit is contained in:
christos 2009-06-19 15:23:26 +00:00
parent d253d157dc
commit e946d9550c
1 changed files with 80 additions and 75 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pwd_mkdb.c,v 1.43 2009/06/18 22:13:56 christos Exp $ */ /* $NetBSD: pwd_mkdb.c,v 1.44 2009/06/19 15:23:26 christos Exp $ */
/* /*
* Copyright (c) 2000, 2009 The NetBSD Foundation, Inc. * Copyright (c) 2000, 2009 The NetBSD Foundation, Inc.
@ -91,7 +91,7 @@ __COPYRIGHT("@(#) Copyright (c) 2000, 2009\
Copyright (c) 1991, 1993, 1994\ Copyright (c) 1991, 1993, 1994\
The Regents of the University of California. All rights reserved."); The Regents of the University of California. All rights reserved.");
__SCCSID("from: @(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94"); __SCCSID("from: @(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94");
__RCSID("$NetBSD: pwd_mkdb.c,v 1.43 2009/06/18 22:13:56 christos Exp $"); __RCSID("$NetBSD: pwd_mkdb.c,v 1.44 2009/06/19 15:23:26 christos Exp $");
#endif /* not lint */ #endif /* not lint */
#if HAVE_NBTOOL_CONFIG_H #if HAVE_NBTOOL_CONFIG_H
@ -167,27 +167,30 @@ static struct pwddb sdb, idb;
void bailout(void) __attribute__((__noreturn__)); void bailout(void) __attribute__((__noreturn__));
void cp(const char *, const char *, mode_t); void cp(const char *, const char *, mode_t);
int deldbent(struct pwddb *, int, void *); void deldbent(struct pwddb *, int, void *);
void error(const char *); void error(const char *);
int getdbent(struct pwddb *, int, void *, struct passwd **); int getdbent(struct pwddb *, int, void *, struct passwd **);
void inconsistancy(void); void inconsistency(void);
void install(const char *, const char *); void install(const char *, const char *);
int main(int, char **); int main(int, char **);
void putdbents(struct pwddb *, struct passwd *, const char *, int, int, int, void putdbents(struct pwddb *, struct passwd *, const char *, int, int,
int); u_int, u_int);
void putyptoken(struct pwddb *); void putyptoken(struct pwddb *);
void rm(const char *); void rm(const char *);
int scan(FILE *, struct passwd *, int *, int *); int scan(FILE *, struct passwd *, int *, int *);
void usage(void) __attribute__((__noreturn__)); void usage(void) __attribute__((__noreturn__));
void wr_error(const char *); void wr_error(const char *);
void checkversion(struct pwddb *);
uint32_t getversion(const char *); uint32_t getversion(const char *);
void setversion(struct pwddb *); void setversion(struct pwddb *);
#ifndef __lint__
#define SWAP(sw) \ #define SWAP(sw) \
((sizeof(sw) == 2 ? (typeof(sw))bswap16((uint16_t)sw) : \ ((sizeof(sw) == 2 ? (typeof(sw))bswap16((uint16_t)sw) : \
(sizeof(sw) == 4 ? (typeof(sw))bswap32((uint32_t)sw) : \ (sizeof(sw) == 4 ? (typeof(sw))bswap32((uint32_t)sw) : \
(sizeof(sw) == 8 ? (typeof(sw))bswap64((uint64_t)sw) : (abort(), 0))))) (sizeof(sw) == 8 ? (typeof(sw))bswap64((uint64_t)sw) : (abort(), 0)))))
#else
#define SWAP(sw) sw
#endif
static void static void
closedb(struct pwddb *db) closedb(struct pwddb *db)
@ -198,7 +201,7 @@ closedb(struct pwddb *db)
static void static void
opendb(struct pwddb *db, const char *dbname, const char *username, opendb(struct pwddb *db, const char *dbname, const char *username,
uint32_t req_version, int flags, int perm) uint32_t req_version, int flags, mode_t perm)
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
@ -206,7 +209,7 @@ opendb(struct pwddb *db, const char *dbname, const char *username,
dbname); dbname);
if (username != NULL) { if (username != NULL) {
snprintf(buf, sizeof(buf), "%s%s", prefix, dbname); (void)snprintf(buf, sizeof(buf), "%s%s", prefix, dbname);
cp(buf, db->dbname, perm); cp(buf, db->dbname, perm);
} }
@ -227,20 +230,25 @@ opendb(struct pwddb *db, const char *dbname, const char *username,
warnx("Use %s -V 1 to upgrade once you've recompiled " warnx("Use %s -V 1 to upgrade once you've recompiled "
"all your binaries.", getprogname()); "all your binaries.", getprogname());
} }
if (verbose)
fprintf(stderr, "%s: %s version %u requested %u\n",
getprogname(), db->fname, db->rversion, db->wversion);
if (db->wversion != db->rversion) { if (db->wversion != db->rversion) {
if (username != NULL) if (username != NULL) {
checkversion(db); (void)fprintf(stderr, "%s: you cannot change a single "
else if (verbose) { "record from version %u to version %u\n",
fprintf(stderr, "%s: changing %s from version " getprogname(), db->rversion, db->wversion);
bailout();
} else if (verbose) {
(void)fprintf(stderr, "%s: changing %s from version "
"%u to version %u\n", "%u to version %u\n",
getprogname(), db->fname, getprogname(), db->fname,
db->rversion, db->wversion); db->rversion, db->wversion);
} }
} else {
if (verbose)
(void)fprintf(stderr, "%s: %s version %u "
"requested %u\n", getprogname(), db->fname,
db->rversion, db->wversion);
} }
setversion(db); setversion(db);
} }
@ -252,7 +260,8 @@ main(int argc, char *argv[])
char *username; char *username;
FILE *fp, *oldfp; FILE *fp, *oldfp;
sigset_t set; sigset_t set;
int dbflg, uid_dbflg, newuser, olduid, flags; u_int dbflg, uid_dbflg;
int newuser, olduid, flags;
struct stat st; struct stat st;
u_int cachesize; u_int cachesize;
uint32_t req_version; uint32_t req_version;
@ -282,7 +291,7 @@ main(int argc, char *argv[])
cachesize = atoi(optarg) * 1024 * 1024; cachesize = atoi(optarg) * 1024 * 1024;
break; break;
case 'd': /* set prefix */ case 'd': /* set prefix */
strlcpy(prefix, optarg, sizeof(prefix)); (void)strlcpy(prefix, optarg, sizeof(prefix));
break; break;
case 'p': /* create V7 "file.orig" */ case 'p': /* create V7 "file.orig" */
makeold = 1; makeold = 1;
@ -323,12 +332,12 @@ main(int argc, char *argv[])
* This could be changed to allow the user to interrupt. * This could be changed to allow the user to interrupt.
* Probably not worth the effort. * Probably not worth the effort.
*/ */
sigemptyset(&set); (void)sigemptyset(&set);
sigaddset(&set, SIGTSTP); (void)sigaddset(&set, SIGTSTP);
sigaddset(&set, SIGHUP); (void)sigaddset(&set, SIGHUP);
sigaddset(&set, SIGINT); (void)sigaddset(&set, SIGINT);
sigaddset(&set, SIGQUIT); (void)sigaddset(&set, SIGQUIT);
sigaddset(&set, SIGTERM); (void)sigaddset(&set, SIGTERM);
(void)sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL); (void)sigprocmask(SIG_BLOCK, &set, (sigset_t *)NULL);
/* We don't care what the user wants. */ /* We don't care what the user wants. */
@ -353,7 +362,7 @@ main(int argc, char *argv[])
openinfo.cachesize = cachesize; openinfo.cachesize = cachesize;
} else { } else {
/* Tweak openinfo values for large passwd files. */ /* Tweak openinfo values for large passwd files. */
cachesize = st.st_size * 20; cachesize = (u_int)(st.st_size * 20);
if (cachesize > MAX_CACHESIZE) if (cachesize > MAX_CACHESIZE)
cachesize = MAX_CACHESIZE; cachesize = MAX_CACHESIZE;
else if (cachesize < MIN_CACHESIZE) else if (cachesize < MIN_CACHESIZE)
@ -465,10 +474,10 @@ main(int argc, char *argv[])
rv = getdbent(&sdb, _PW_KEYBYNUM, &lineno, &tpwd); rv = getdbent(&sdb, _PW_KEYBYNUM, &lineno, &tpwd);
if (newuser) { if (newuser) {
if (rv == 0) if (rv == 0)
inconsistancy(); inconsistency();
} else if (rv == -1 || } else if (rv == -1 ||
strcmp(username, tpwd->pw_name) != 0) strcmp(username, tpwd->pw_name) != 0)
inconsistancy(); inconsistency();
else if ((uid_t)olduid != pwd.pw_uid) { else if ((uid_t)olduid != pwd.pw_uid) {
/* /*
* If we're changing UID, remove the BYUID * If we're changing UID, remove the BYUID
@ -483,7 +492,7 @@ main(int argc, char *argv[])
deldbent(&sdb, _PW_KEYBYUID, &olduid); deldbent(&sdb, _PW_KEYBYUID, &olduid);
} }
} else } else
inconsistancy(); inconsistency();
} }
/* /*
@ -575,7 +584,7 @@ scan(FILE *fp, struct passwd *pw, int *flags, int *lineno)
char *p; char *p;
int oflags; int oflags;
if (fgets(line, sizeof(line), fp) == NULL) if (fgets(line, (int)sizeof(line), fp) == NULL)
return (0); return (0);
(*lineno)++; (*lineno)++;
@ -590,8 +599,10 @@ scan(FILE *fp, struct passwd *pw, int *flags, int *lineno)
error(pname); error(pname);
} }
*p = '\0'; *p = '\0';
if (strcmp(line, "+") == 0) if (strcmp(line, "+") == 0) {
strcpy(line, "+:::::::::"); /* pw_scan() can't handle "+" */ /* pw_scan() can't handle "+" */
(void)strcpy(line, "+:::::::::");
}
oflags = 0; oflags = 0;
if (!pw_scan(line, pw, &oflags)) { if (!pw_scan(line, pw, &oflags)) {
warnx("at line #%d", *lineno); warnx("at line #%d", *lineno);
@ -610,7 +621,7 @@ install(const char *from, const char *to)
char errbuf[BUFSIZ]; char errbuf[BUFSIZ];
int sverrno; int sverrno;
snprintf(buf, sizeof(buf), "%s%s", prefix, to); (void)snprintf(buf, sizeof(buf), "%s%s", prefix, to);
if (rename(from, buf)) { if (rename(from, buf)) {
sverrno = errno; sverrno = errno;
(void)snprintf(errbuf, sizeof(errbuf), "%s to %s", from, buf); (void)snprintf(errbuf, sizeof(errbuf), "%s to %s", from, buf);
@ -631,14 +642,15 @@ void
cp(const char *from, const char *to, mode_t mode) cp(const char *from, const char *to, mode_t mode)
{ {
static char buf[MAXBSIZE]; static char buf[MAXBSIZE];
int from_fd, rcount, to_fd, wcount, sverrno; int from_fd, to_fd, sverrno;
ssize_t rcount, wcount;
if ((from_fd = open(from, O_RDONLY, 0)) < 0) if ((from_fd = open(from, O_RDONLY, 0)) < 0)
error(from); error(from);
if ((to_fd = open(to, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) if ((to_fd = open(to, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0)
error(to); error(to);
while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) { while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
wcount = write(to_fd, buf, rcount); wcount = write(to_fd, buf, (size_t)rcount);
if (rcount != wcount || wcount == -1) { if (rcount != wcount || wcount == -1) {
sverrno = errno; sverrno = errno;
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to); (void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
@ -679,7 +691,7 @@ error(const char *str)
} }
void void
inconsistancy(void) inconsistency(void)
{ {
warnx("text files and databases are inconsistent"); warnx("text files and databases are inconsistent");
@ -726,7 +738,7 @@ getversion(const char *fname)
warnx("Bad VERSION record in database"); warnx("Bad VERSION record in database");
goto out; goto out;
} }
memcpy(&version, data.data, sizeof(version)); (void)memcpy(&version, data.data, sizeof(version));
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case 1: case 1:
if (ret == 1) if (ret == 1)
@ -740,6 +752,7 @@ getversion(const char *fname)
out: out:
(*db->close)(db); (*db->close)(db);
bailout(); bailout();
/*NOTREACHED*/
} }
void void
@ -758,14 +771,6 @@ setversion(struct pwddb *db)
} }
} }
void
checkversion(struct pwddb *db)
{
(void)fprintf(stderr, "%s: you cannot change a single "
"record from version %u to version %u\n", getprogname(),
db->rversion, db->wversion);
bailout();
}
/* /*
* Write entries to a database for a single user. * Write entries to a database for a single user.
@ -784,16 +789,16 @@ checkversion(struct pwddb *db)
void void
putdbents(struct pwddb *db, struct passwd *pw, const char *passwd, int flags, putdbents(struct pwddb *db, struct passwd *pw, const char *passwd, int flags,
int lineno, int dbflg, int uid_dbflg) int lineno, u_int dbflg, u_int uid_dbflg)
{ {
struct passwd pwd; struct passwd pwd;
char buf[MAX(MAXPATHLEN, LINE_MAX * 2)], tbuf[1024], *p; char buf[MAX(MAXPATHLEN, LINE_MAX * 2)], tbuf[1024], *p;
DBT data, key; DBT data, key;
const char *t; const char *t;
u_int32_t x; u_int32_t x;
int len; size_t len;
memcpy(&pwd, pw, sizeof(pwd)); (void)memcpy(&pwd, pw, sizeof(pwd));
data.data = (u_char *)buf; data.data = (u_char *)buf;
key.data = (u_char *)tbuf; key.data = (u_char *)tbuf;
@ -805,23 +810,23 @@ putdbents(struct pwddb *db, struct passwd *pw, const char *passwd, int flags,
#define WRITEPWTIMEVAR(pwvar) \ #define WRITEPWTIMEVAR(pwvar) \
do { \ do { \
if (db->wversion == 0 && \ if (db->wversion == 0 && \
sizeof(pwvar) == sizeof(uint64_t)) { \ /*CONSTCOND*/sizeof(pwvar) == sizeof(uint64_t)) { \
uint32_t tmp = (uint32_t)pwvar; \ uint32_t tmp = (uint32_t)pwvar; \
if (lorder != BYTE_ORDER) \ if (lorder != BYTE_ORDER) \
tmp = SWAP(tmp); \ tmp = SWAP(tmp); \
memmove(p, &tmp, sizeof(tmp)); \ (void)memmove(p, &tmp, sizeof(tmp)); \
p += sizeof(tmp); \ p += sizeof(tmp); \
} else if (db->wversion == 1 && \ } else if (db->wversion == 1 && \
sizeof(pwvar) == sizeof(uint32_t)) { \ /*CONSTCOND*/sizeof(pwvar) == sizeof(uint32_t)) { \
uint64_t tmp = pwvar; \ uint64_t tmp = pwvar; \
if (lorder != BYTE_ORDER) \ if (lorder != BYTE_ORDER) \
tmp = SWAP(tmp); \ tmp = SWAP(tmp); \
memmove(p, &tmp, sizeof(tmp)); \ (void)memmove(p, &tmp, sizeof(tmp)); \
p += sizeof(tmp); \ p += sizeof(tmp); \
} else { \ } else { \
if (lorder != BYTE_ORDER) \ if (lorder != BYTE_ORDER) \
pwvar = SWAP(pwvar); \ pwvar = SWAP(pwvar); \
memmove(p, &pwvar, sizeof(pwvar)); \ (void)memmove(p, &pwvar, sizeof(pwvar)); \
p += sizeof(pwvar); \ p += sizeof(pwvar); \
} \ } \
} while (/*CONSTCOND*/0) } while (/*CONSTCOND*/0)
@ -830,9 +835,9 @@ putdbents(struct pwddb *db, struct passwd *pw, const char *passwd, int flags,
p = buf; p = buf;
COMPACT(pwd.pw_name); COMPACT(pwd.pw_name);
COMPACT(passwd); COMPACT(passwd);
memmove(p, &pwd.pw_uid, sizeof(pwd.pw_uid)); (void)memmove(p, &pwd.pw_uid, sizeof(pwd.pw_uid));
p += sizeof(pwd.pw_uid); p += sizeof(pwd.pw_uid);
memmove(p, &pwd.pw_gid, sizeof(pwd.pw_gid)); (void)memmove(p, &pwd.pw_gid, sizeof(pwd.pw_gid));
p += sizeof(pwd.pw_gid); p += sizeof(pwd.pw_gid);
WRITEPWTIMEVAR(pwd.pw_change); WRITEPWTIMEVAR(pwd.pw_change);
COMPACT(pwd.pw_class); COMPACT(pwd.pw_class);
@ -843,14 +848,14 @@ putdbents(struct pwddb *db, struct passwd *pw, const char *passwd, int flags,
x = flags; x = flags;
if (lorder != BYTE_ORDER) if (lorder != BYTE_ORDER)
x = SWAP(x); x = SWAP(x);
memmove(p, &x, sizeof(x)); (void)memmove(p, &x, sizeof(x));
p += sizeof(flags); p += sizeof(flags);
data.size = p - buf; data.size = p - buf;
/* Store insecure by name. */ /* Store insecure by name. */
tbuf[0] = _PW_KEYBYNAME; tbuf[0] = _PW_KEYBYNAME;
len = strlen(pwd.pw_name); len = strlen(pwd.pw_name);
memmove(tbuf + 1, pwd.pw_name, len); (void)memmove(tbuf + 1, pwd.pw_name, len);
key.size = len + 1; key.size = len + 1;
if ((*db->db->put)(db->db, &key, &data, dbflg) == -1) if ((*db->db->put)(db->db, &key, &data, dbflg) == -1)
wr_error(db->dbname); wr_error(db->dbname);
@ -860,33 +865,33 @@ putdbents(struct pwddb *db, struct passwd *pw, const char *passwd, int flags,
x = lineno; x = lineno;
if (lorder != BYTE_ORDER) if (lorder != BYTE_ORDER)
x = SWAP(x); x = SWAP(x);
memmove(tbuf + 1, &x, sizeof(x)); (void)memmove(tbuf + 1, &x, sizeof(x));
key.size = sizeof(x) + 1; key.size = sizeof(x) + 1;
if ((*db->db->put)(db->db, &key, &data, dbflg) == -1) if ((*db->db->put)(db->db, &key, &data, dbflg) == -1)
wr_error(db->dbname); wr_error(db->dbname);
/* Store insecure by uid. */ /* Store insecure by uid. */
tbuf[0] = _PW_KEYBYUID; tbuf[0] = _PW_KEYBYUID;
memmove(tbuf + 1, &pwd.pw_uid, sizeof(pwd.pw_uid)); (void)memmove(tbuf + 1, &pwd.pw_uid, sizeof(pwd.pw_uid));
key.size = sizeof(pwd.pw_uid) + 1; key.size = sizeof(pwd.pw_uid) + 1;
if ((*db->db->put)(db->db, &key, &data, uid_dbflg) == -1) if ((*db->db->put)(db->db, &key, &data, uid_dbflg) == -1)
wr_error(db->dbname); wr_error(db->dbname);
} }
int void
deldbent(struct pwddb *db, int type, void *keyp) deldbent(struct pwddb *db, int type, void *keyp)
{ {
char tbuf[1024]; char tbuf[1024];
DBT key; DBT key;
u_int32_t x; u_int32_t x;
int len, rv; size_t len;
key.data = (u_char *)tbuf; key.data = (u_char *)tbuf;
switch (tbuf[0] = type) { switch (tbuf[0] = type) {
case _PW_KEYBYNAME: case _PW_KEYBYNAME:
len = strlen((char *)keyp); len = strlen((char *)keyp);
memcpy(tbuf + 1, keyp, len); (void)memcpy(tbuf + 1, keyp, len);
key.size = len + 1; key.size = len + 1;
break; break;
@ -895,14 +900,13 @@ deldbent(struct pwddb *db, int type, void *keyp)
x = *(int *)keyp; x = *(int *)keyp;
if (lorder != BYTE_ORDER) if (lorder != BYTE_ORDER)
x = SWAP(x); x = SWAP(x);
memmove(tbuf + 1, &x, sizeof(x)); (void)memmove(tbuf + 1, &x, sizeof(x));
key.size = sizeof(x) + 1; key.size = sizeof(x) + 1;
break; break;
} }
if ((rv = (*db->db->del)(db->db, &key, 0)) == -1) if ((*db->db->del)(db->db, &key, 0) == -1)
wr_error(db->dbname); wr_error(db->dbname);
return (rv);
} }
int int
@ -913,7 +917,8 @@ getdbent(struct pwddb *db, int type, void *keyp, struct passwd **tpwd)
char tbuf[1024], *p; char tbuf[1024], *p;
DBT key, data; DBT key, data;
u_int32_t x; u_int32_t x;
int len, rv; size_t len;
int rv;
data.data = (u_char *)buf; data.data = (u_char *)buf;
data.size = sizeof(buf); data.size = sizeof(buf);
@ -922,7 +927,7 @@ getdbent(struct pwddb *db, int type, void *keyp, struct passwd **tpwd)
switch (tbuf[0] = type) { switch (tbuf[0] = type) {
case _PW_KEYBYNAME: case _PW_KEYBYNAME:
len = strlen((char *)keyp); len = strlen((char *)keyp);
memcpy(tbuf + 1, keyp, len); (void)memcpy(tbuf + 1, keyp, len);
key.size = len + 1; key.size = len + 1;
break; break;
@ -931,7 +936,7 @@ getdbent(struct pwddb *db, int type, void *keyp, struct passwd **tpwd)
x = *(int *)keyp; x = *(int *)keyp;
if (lorder != BYTE_ORDER) if (lorder != BYTE_ORDER)
x = SWAP(x); x = SWAP(x);
memmove(tbuf + 1, &x, sizeof(x)); (void)memmove(tbuf + 1, &x, sizeof(x));
key.size = sizeof(x) + 1; key.size = sizeof(x) + 1;
break; break;
} }
@ -950,33 +955,33 @@ getdbent(struct pwddb *db, int type, void *keyp, struct passwd **tpwd)
while (*p++ != '\0') while (*p++ != '\0')
continue; continue;
memcpy(&pwd.pw_uid, p, sizeof(pwd.pw_uid)); (void)memcpy(&pwd.pw_uid, p, sizeof(pwd.pw_uid));
p += sizeof(pwd.pw_uid); p += sizeof(pwd.pw_uid);
memcpy(&pwd.pw_gid, p, sizeof(pwd.pw_gid)); (void)memcpy(&pwd.pw_gid, p, sizeof(pwd.pw_gid));
p += sizeof(pwd.pw_gid); p += sizeof(pwd.pw_gid);
#define READPWTIMEVAR(pwvar) \ #define READPWTIMEVAR(pwvar) \
do { \ do { \
if (db->rversion == 0 && \ if (db->rversion == 0 && \
sizeof(pwvar) == sizeof(uint64_t)) { \ /*CONSTCOND*/sizeof(pwvar) == sizeof(uint64_t)) { \
uint32_t tmp; \ uint32_t tmp; \
memcpy(&tmp, p, sizeof(tmp)); \ (void)memcpy(&tmp, p, sizeof(tmp)); \
p += sizeof(tmp); \ p += sizeof(tmp); \
if (lorder != BYTE_ORDER) \ if (lorder != BYTE_ORDER) \
pwvar = SWAP(tmp); \ pwvar = SWAP(tmp); \
else \ else \
pwvar = tmp; \ pwvar = tmp; \
} else if (db->rversion == 1 && \ } else if (db->rversion == 1 && \
sizeof(pwvar) == sizeof(uint32_t)) { \ /*CONSTCOND*/sizeof(pwvar) == sizeof(uint32_t)) { \
uint64_t tmp; \ uint64_t tmp; \
memcpy(&tmp, p, sizeof(tmp)); \ (void)memcpy(&tmp, p, sizeof(tmp)); \
p += sizeof(tmp); \ p += sizeof(tmp); \
if (lorder != BYTE_ORDER) \ if (lorder != BYTE_ORDER) \
pwvar = (uint32_t)SWAP(tmp); \ pwvar = (uint32_t)SWAP(tmp); \
else \ else \
pwvar = (uint32_t)tmp; \ pwvar = (uint32_t)tmp; \
} else { \ } else { \
memcpy(&pwvar, p, sizeof(pwvar)); \ (void)memcpy(&pwvar, p, sizeof(pwvar)); \
p += sizeof(pwvar); \ p += sizeof(pwvar); \
if (lorder != BYTE_ORDER) \ if (lorder != BYTE_ORDER) \
pwvar = SWAP(pwvar); \ pwvar = SWAP(pwvar); \