Skip to content

Commit

Permalink
compilerflag now set to c99 standard, added patches for portability a…
Browse files Browse the repository at this point in the history
…nd related compiler warnings
  • Loading branch information
tschudin committed Jul 29, 2013
1 parent 15c49a8 commit 1349195
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
@@ -1,8 +1,8 @@
# Makefile

CC=gcc
#MYCFLAGS=-Wall -pedantic -std=c99 -g
MYCFLAGS= -Wall -g -O0
MYCFLAGS=-O3 -Wall -pedantic -std=c99 -g -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED
#MYCFLAGS= -Wall -g -O0
EXTLIBS= -lcrypto
EXTMAKE=
EXTMAKECLEAN=
Expand Down
4 changes: 4 additions & 0 deletions ccn-lite-minimalrelay.c
Expand Up @@ -39,6 +39,10 @@
#include <arpa/inet.h>
#include <netinet/in.h>

#if !(defined(_BSD_SOURCE) && defined(SVID_SOURCE))
int inet_aton(const char *cp, struct in_addr *inp);
#endif

// ----------------------------------------------------------------------

#define DEBUGMSG(LVL, ...) do { \
Expand Down
10 changes: 6 additions & 4 deletions ccn-lite-relay.c
Expand Up @@ -467,6 +467,7 @@ ccnl_populate_cache(struct ccnl_relay_s *ccnl, char *path)
{
DIR *dir;
struct dirent *de;
int datalen;

DEBUGMSG(99, "ccnl_populate_cache %s\n", path);

Expand Down Expand Up @@ -495,17 +496,18 @@ ccnl_populate_cache(struct ccnl_relay_s *ccnl, char *path)
}
buf = (struct ccnl_buf_s *) ccnl_malloc(sizeof(*buf) +
s.st_size);
buf->datalen = s.st_size;
read(fd, buf->data, s.st_size);
datalen = read(fd, buf->data, s.st_size);
close(fd);
if (buf->datalen > 1 &&
if (datalen == s.st_size && datalen >= 2 &&
buf->data[0] == 0x04 && buf->data[1] == 0x82) {
struct ccnl_prefix_s *prefix = 0;
struct ccnl_content_s *c = 0;
struct ccnl_buf_s *nonce=0, *ppkd=0, *pkt = 0;
unsigned char *content, *data = buf->data + 2;
int contlen, datalen = buf->datalen - 2;
int contlen;

buf->datalen = datalen;
datalen -= 2;
pkt = ccnl_extract_prefix_nonce_ppkd(&data, &datalen, 0, 0,
0, 0, &prefix, &nonce, &ppkd, &content, &contlen);
if (!pkt) {
Expand Down
4 changes: 2 additions & 2 deletions ccnl-core.c
Expand Up @@ -634,7 +634,7 @@ ccnl_interest_propagate(struct ccnl_relay_s *ccnl, struct ccnl_interest_s *i)
DEBUGMSG(40, " ccnl_interest_propagate, rc=%d/%d\n", rc, fwd->prefix->compcnt);
if (rc < fwd->prefix->compcnt)
continue;
DEBUGMSG(40, " ccnl_interest_propagate, fwd==%p\n", fwd);
DEBUGMSG(40, " ccnl_interest_propagate, fwd==%p\n", (void*)fwd);
// suppress forwarding to origin of interest, except wireless
if (!i->from || fwd->face != i->from ||
(i->from->flags & CCNL_FACE_FLAGS_REFLECT))
Expand Down Expand Up @@ -854,7 +854,7 @@ int
ccnl_core_RX_i_or_c(struct ccnl_relay_s *relay, struct ccnl_face_s *from,
unsigned char **data, int *datalen)
{
int rc=-1, scope=3, aok=3, minsfx=0, maxsfx=CCNL_MAX_NAME_COMP, contlen;
int rc= -1, scope=3, aok=3, minsfx=0, maxsfx=CCNL_MAX_NAME_COMP, contlen;
struct ccnl_buf_s *buf = 0, *nonce=0, *ppkd=0;
struct ccnl_interest_s *i = 0;
struct ccnl_content_s *c = 0;
Expand Down
6 changes: 4 additions & 2 deletions ccnl-ext-mgmt.c
Expand Up @@ -645,7 +645,8 @@ ccnl_mgmt_newface(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
unsigned char faceidstr[100];
unsigned char retstr[200];

DEBUGMSG(99, "ccnl_mgmt_newface from=%p, ifndx=%d\n", from, from->ifndx);
DEBUGMSG(99, "ccnl_mgmt_newface from=%p, ifndx=%d\n",
(void*) from, from->ifndx);
action = macsrc = ip4src = proto = host = port = NULL;
path = frag = flags = NULL;

Expand Down Expand Up @@ -833,7 +834,8 @@ ccnl_mgmt_setfrag(struct ccnl_relay_s *ccnl, struct ccnl_buf_s *orig,
// unsigned char contentobj[2000];
// unsigned char faceinst[2000];

DEBUGMSG(99, "ccnl_mgmt_setfrag from=%p, ifndx=%d\n", from, from->ifndx);
DEBUGMSG(99, "ccnl_mgmt_setfrag from=%p, ifndx=%d\n",
(void*) from, from->ifndx);
action = faceid = frag = mtu = NULL;

buf = prefix->comp[3];
Expand Down
4 changes: 4 additions & 0 deletions ccnl-includes.h
Expand Up @@ -44,6 +44,10 @@
#include <netinet/in.h>
#include <net/if.h> // IFNAMSIZE, if_nametoindex

#if !(defined(_BSD_SOURCE) && defined(SVID_SOURCE))
int inet_aton(const char *cp, struct in_addr *inp);
#endif

#if defined(__FreeBSD__)
# include <sys/types.h>
# undef USE_ETHERNET
Expand Down

0 comments on commit 1349195

Please sign in to comment.