Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/am-utils/dist/amd fix type-punned warnings usin...
details: https://anonhg.NetBSD.org/src/rev/f06226901131
branches: trunk
changeset: 768455:f06226901131
user: christos <christos%NetBSD.org@localhost>
date: Wed Aug 17 08:22:50 2011 +0000
description:
fix type-punned warnings using memcpy
diffstat:
external/bsd/am-utils/dist/amd/readdir.c | 45 +++++++++++++++++++------------
1 files changed, 28 insertions(+), 17 deletions(-)
diffs (123 lines):
diff -r d018019bb173 -r f06226901131 external/bsd/am-utils/dist/amd/readdir.c
--- a/external/bsd/am-utils/dist/amd/readdir.c Wed Aug 17 08:06:38 2011 +0000
+++ b/external/bsd/am-utils/dist/amd/readdir.c Wed Aug 17 08:22:50 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: readdir.c,v 1.1.1.2 2009/03/20 20:26:50 christos Exp $ */
+/* $NetBSD: readdir.c,v 1.2 2011/08/17 08:22:50 christos Exp $ */
/*
* Copyright (c) 1997-2009 Erez Zadok
@@ -57,6 +57,7 @@
#define DOT_DOT_COOKIE (u_int) 1
#define MAX_CHAIN 2048
+static const u_int zero = 0, dot_dot_cookie = DOT_DOT_COOKIE;
/****************************************************************************
*** FORWARD DEFINITIONS ***
@@ -181,7 +182,7 @@
/* we have space. put entry in next cell */
++last_cookie;
chain[num_entries].ne_fileid = (u_int) last_cookie;
- *(u_int *) chain[num_entries].ne_cookie = (u_int) last_cookie;
+ memcpy(chain[num_entries].ne_cookie, &last_cookie, sizeof(last_cookie));
chain[num_entries].ne_name = key;
if (num_entries < max_entries - 1) { /* link to next one */
chain[num_entries].ne_nextentry = &chain[num_entries + 1];
@@ -255,7 +256,7 @@
ep[0].ne_fileid = mp->am_gen;
ep[0].ne_name = ".";
ep[0].ne_nextentry = &ep[1];
- *(u_int *) ep[0].ne_cookie = 0;
+ memcpy(ep[0].ne_cookie, &zero, sizeof(zero));
/* construct ".." */
if (mp->am_parent)
@@ -265,7 +266,7 @@
ep[1].ne_name = "..";
ep[1].ne_nextentry = NULL;
- *(u_int *) ep[1].ne_cookie = DOT_DOT_COOKIE;
+ memcpy(ep[1].ne_cookie, &dot_dot_cookie, sizeof(dot_dot_cookie));
/*
* If map is browsable, call a function make_entry_chain() to construct
@@ -302,9 +303,12 @@
nfsentry *ne;
for (j = 0, ne = te; ne; ne = ne->ne_nextentry)
plog(XLOG_DEBUG, "gen2 key %4d \"%s\"", j++, ne->ne_name);
- for (j = 0, ne = ep; ne; ne = ne->ne_nextentry)
- plog(XLOG_DEBUG, "gen2+ key %4d \"%s\" fi=%d ck=%d",
- j++, ne->ne_name, ne->ne_fileid, *(u_int *)ne->ne_cookie);
+ for (j = 0, ne = ep; ne; ne = ne->ne_nextentry) {
+ u_int cookie;
+ memcpy(&cookie, ne->ne_cookie, sizeof(cookie));
+ plog(XLOG_DEBUG, "gen2+ key %4d \"%s\" fi=%d ck=%u",
+ j++, ne->ne_name, ne->ne_fileid, cookie);
+ }
plog(XLOG_DEBUG, "EOF is %d", dp->dl_eof);
}
return 0;
@@ -414,7 +418,7 @@
ep[0].ne_fileid = mp->am_gen;
ep[0].ne_name = ".";
ep[0].ne_nextentry = &ep[1];
- *(u_int *) ep[0].ne_cookie = 0;
+ memcpy(ep[0].ne_cookie, &zero, sizeof(zero));
/* construct ".." */
if (mp->am_parent)
@@ -423,7 +427,8 @@
ep[1].ne_fileid = mp->am_gen;
ep[1].ne_name = "..";
ep[1].ne_nextentry = NULL;
- *(u_int *) ep[1].ne_cookie = (xp ? xp->am_gen : DOT_DOT_COOKIE);
+ memcpy(ep[1].ne_cookie, (xp ? &xp->am_gen : &dot_dot_cookie),
+ sizeof(dot_dot_cookie));
if (!xp)
dp->dl_eof = TRUE; /* by default assume readdir done */
@@ -431,9 +436,12 @@
if (amuDebug(D_READDIR)) {
nfsentry *ne;
int j;
- for (j = 0, ne = ep; ne; ne = ne->ne_nextentry)
- plog(XLOG_DEBUG, "gen1 key %4d \"%s\" fi=%d ck=%d",
- j++, ne->ne_name, ne->ne_fileid, *(u_int *)ne->ne_cookie);
+ for (j = 0, ne = ep; ne; ne = ne->ne_nextentry) {
+ u_int cookie;
+ memcpy(&cookie, ne->ne_cookie, sizeof(cookie));
+ plog(XLOG_DEBUG, "gen1 key %4d \"%s\" fi=%d ck=%u",
+ j++, ne->ne_name, ne->ne_fileid, cookie);
+ }
}
return 0;
}
@@ -462,9 +470,9 @@
am_node *xp_next = next_nonerror_node(xp->am_osib);
if (xp_next) {
- *(u_int *) ep->ne_cookie = xp_next->am_gen;
+ memcpy(ep->ne_cookie, &xp_next->am_gen, sizeof(xp_next->am_gen));
} else {
- *(u_int *) ep->ne_cookie = DOT_DOT_COOKIE;
+ memcpy(ep->ne_cookie, &dot_dot_cookie, sizeof(dot_dot_cookie));
dp->dl_eof = TRUE;
}
@@ -490,9 +498,12 @@
if (amuDebug(D_READDIR)) {
nfsentry *ne;
int j;
- for (j=0,ne=ep; ne; ne=ne->ne_nextentry)
- plog(XLOG_DEBUG, "gen2 key %4d \"%s\" fi=%d ck=%d",
- j++, ne->ne_name, ne->ne_fileid, *(u_int *)ne->ne_cookie);
+ for (j=0,ne=ep; ne; ne=ne->ne_nextentry) {
+ u_int cookie;
+ memcpy(&cookie, ne->ne_cookie, sizeof(cookie));
+ plog(XLOG_DEBUG, "gen2 key %4d \"%s\" fi=%d ck=%u",
+ j++, ne->ne_name, ne->ne_fileid, cookie);
+ }
}
return 0;
}
Home |
Main Index |
Thread Index |
Old Index