[PATCH 1/2] FreeBSD 10.x has fmemopen in libc, so check __FreeBSD_version and set defines appropriately.

66 views
Skip to first unread message

murray stokely

unread,
Jul 11, 2013, 11:46:14 AM7/11/13
to packe...@googlegroups.com, murray stokely
---
gtests/net/packetdrill/platforms.h | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/gtests/net/packetdrill/platforms.h b/gtests/net/packetdrill/platforms.h
index cb511b2..b5d8fc1 100644
--- a/gtests/net/packetdrill/platforms.h
+++ b/gtests/net/packetdrill/platforms.h
@@ -43,11 +43,15 @@

#if defined(__FreeBSD__)

+#include <sys/param.h>
#define USE_LIBPCAP 1
#define TUN_PATH "/dev/tun0"
#define TUN_DEV "tun0"

#define HAVE_TCP_INFO 1
+#if __FreeBSD_version > 1000028
+#define HAVE_FMEMOPEN 1
+#endif

#include "open_memstream.h"
#include "fmemopen.h"
--
1.8.3.2

murray stokely

unread,
Jul 11, 2013, 11:46:15 AM7/11/13
to packe...@googlegroups.com, murray stokely
---
gtests/net/packetdrill/script.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gtests/net/packetdrill/script.c b/gtests/net/packetdrill/script.c
index 7d45247..3095770 100644
--- a/gtests/net/packetdrill/script.c
+++ b/gtests/net/packetdrill/script.c
@@ -261,7 +261,7 @@ void free_expression(struct expression *expression)
{
if (expression == NULL)
return;
- if ((expression->type < 0) || (expression->type >= NUM_EXPR_TYPES))
+ if (expression->type >= NUM_EXPR_TYPES)
assert(!"bad expression type");
switch (expression->type) {
case EXPR_ELLIPSIS:
@@ -460,7 +460,7 @@ static int evaluate(struct expression *in,
*out_ptr = out;
out->type = in->type; /* most types of expression stay the same */

- if ((in->type < 0) || (in->type >= NUM_EXPR_TYPES)) {
+ if (in->type >= NUM_EXPR_TYPES) {
asprintf(error, "bad expression type: %d", in->type);
return STATUS_ERR;
}
--
1.8.3.2

mnei...@acm.org

unread,
Jul 11, 2013, 6:29:14 AM7/11/13
to packe...@googlegroups.com, murray stokely
For what it's worth, the C90 and C99 standards don't restrict enumerated types to unsigned values.

---
C90 - http://flash-gordon.me.uk/ansi.c.txt:
3.5.2.2 Enumeration specifiers
[...]
Each enumerated type shall be compatible with an integer type; the choice of type is implementation-defined.

---
C99 - http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf:
6.7.2.2  Enumeration specifiers
[...]
Each  enumerated  type  shall  be  compatible  with char, a signed  integer  type,  or  an unsigned  integer  type. The  choice  of  type  is  implementation-defined, 110) but shall  be capable  of  representing  the  values  of  all  the  members  of  the  enumeration.

2013年7月11日木曜日 3時46分39秒 UTC-5 Murray Stokely:

Neal Cardwell

unread,
Nov 15, 2013, 9:39:21 PM11/15/13
to murray stokely, packe...@googlegroups.com, murray stokely
Thanks, Murray! I've merged this in. Sorry for the delay.

neal
> --
> You received this message because you are subscribed to the Google Groups "packetdrill" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to packetdrill...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Neal Cardwell

unread,
Nov 15, 2013, 9:41:17 PM11/15/13
to mnei...@acm.org, packe...@googlegroups.com, murray stokely
Thanks to you both, Murray and Mike. I've merged in a variant on this
patch that continues to check both the lower and upper bound, but now
compiles on FreeBSD 10.0 beta 3 with clang.

neal
Reply all
Reply to author
Forward
0 new messages