[Pkg-privacy-commits] [onioncat] 233/241: fixed aliasing and unused warnings
Intrigeri
intrigeri at moszumanska.debian.org
Wed Aug 26 16:17:17 UTC 2015
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch upstream-master
in repository onioncat.
commit 21ed67c306375167a9c2fccfac79c453945b0c27
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Tue Mar 18 11:44:16 2014 +0000
fixed aliasing and unused warnings
git-svn-id: https://www.cypherpunk.at/svn/onioncat/trunk@562 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
src/ocatroute.c | 30 ++++++++++++++++++++++++++----
src/ocatthread.c | 6 +++++-
2 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/src/ocatroute.c b/src/ocatroute.c
index fd9bb78..fcae6ff 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -785,6 +785,28 @@ void *socket_acceptor(void *p)
}
+#ifdef HAVE_STRUCT_IPHDR
+/* helper function to avoid pointer aliasing */
+static uint32_t get_saddr(const struct iphdr *ihdr)
+{
+ return ihdr->daddr;
+}
+#else
+/* helper function to avoid pointer aliasing */
+static uint32_t get_saddr(const struct ip *ihdr)
+{
+ return ihdr->ip_dst.s_addr;
+}
+#endif
+
+
+/* helper function to avoid pointer aliasing */
+static struct in6_addr *get_6dst_ptr(struct ip6_hdr *i6hdr)
+{
+ return &i6hdr->ip6_dst;
+}
+
+
void packet_forwarder(void)
{
char buf[FRAME_SIZE];
@@ -890,8 +912,8 @@ void packet_forwarder(void)
}
#endif
- if (!(dest = ipv6_lookup_route(&((struct ip6_hdr*) &buf[4])->ip6_dst)))
- dest = &((struct ip6_hdr*) &buf[4])->ip6_dst;
+ if (!(dest = ipv6_lookup_route(get_6dst_ptr((struct ip6_hdr*) &buf[4]))))
+ dest = get_6dst_ptr((struct ip6_hdr*) &buf[4]);
}
else if (get_tunheader(buf) == CNF(fhd_key[IPV4_KEY]))
{
@@ -902,9 +924,9 @@ void packet_forwarder(void)
}
#ifdef HAVE_STRUCT_IPHDR
- in.s_addr = ((struct iphdr*) &buf[4])->daddr;
+ in.s_addr = get_saddr((struct iphdr*) &buf[4]);
#else
- in.s_addr = ((struct ip*) &buf[4])->ip_dst.s_addr;
+ in.s_addr = get_saddr((struct ip*) &buf[4]);
#endif
if (!(dest = ipv4_lookup_route(ntohl(in.s_addr))))
{
diff --git a/src/ocatthread.c b/src/ocatthread.c
index d49cfe8..99594f6 100644
--- a/src/ocatthread.c
+++ b/src/ocatthread.c
@@ -29,7 +29,6 @@
// global thread id var and mutex for thread initializiation
static int thread_id_ = 0;
-static int exit_cnt_ = 0;
pthread_mutex_t thread_mutex_ = PTHREAD_MUTEX_INITIALIZER;
OcatThread_t *octh_ = NULL;
@@ -70,7 +69,10 @@ void *thread_run(void *p)
OcatThread_t **tl;
void *r;
sigset_t ss;
+#ifdef DEBUG
int ecnt, icnt;
+ static int exit_cnt_ = 0;
+#endif
// block all signals for the thread
sigfillset(&ss);
@@ -95,8 +97,10 @@ void *thread_run(void *p)
*tl = (*tl)->next;
free(p);
}
+#ifdef DEBUG
ecnt = ++exit_cnt_;
icnt = thread_id_;
+#endif
pthread_mutex_unlock(&thread_mutex_);
log_debug("_exit_ thread, %d inits, %d exits", icnt, ecnt);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git
More information about the Pkg-privacy-commits
mailing list