From a946e22101b830ff117bb4b9b605a4d1822f81a4 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 26 Dec 2014 17:16:15 +0000 Subject: [PATCH] - firedns.c: replaced unsigned short with explicit uint16_t; removed related checks in configure.ac git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@5156 82007160-df01-0410-b94d-b575c5fd34c7 --- configure | 285 ------------------------------------------------- configure.ac | 20 ---- src/firedns.c | 26 ++--- src/setup.h.in | 25 ----- 4 files changed, 13 insertions(+), 343 deletions(-) diff --git a/configure b/configure index 9f430f7..4335723 100755 --- a/configure +++ b/configure @@ -1926,189 +1926,6 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid; break -else - as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=$ac_mid; break -else - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - ac_lo= ac_hi= -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid -else - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -13190,108 +13007,6 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h esac -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 -$as_echo_n "checking size of int... " >&6; } -if ${ac_cv_sizeof_int+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_int" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (int) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_int=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 -$as_echo "$ac_cv_sizeof_int" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_INT $ac_cv_sizeof_int -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 -$as_echo_n "checking size of short... " >&6; } -if ${ac_cv_sizeof_short+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_short" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (short) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_short=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 -$as_echo "$ac_cv_sizeof_short" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_SHORT $ac_cv_sizeof_short -_ACEOF - - -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 -$as_echo_n "checking size of long... " >&6; } -if ${ac_cv_sizeof_long+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : - -else - if test "$ac_cv_type_long" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (long) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_long=0 - fi -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 -$as_echo "$ac_cv_sizeof_long" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define SIZEOF_LONG $ac_cv_sizeof_long -_ACEOF - - - - - diff --git a/configure.ac b/configure.ac index 7536469..2e4e7cd 100644 --- a/configure.ac +++ b/configure.ac @@ -65,26 +65,6 @@ AC_CHECK_FUNCS(gethostbyname) dnl AIX fun AC_C_BIGENDIAN -AC_CHECK_SIZEOF(int) -AC_CHECK_SIZEOF(short) -AC_CHECK_SIZEOF(long) - - -AH_BOTTOM([ -#if SIZEOF_INT==4 -typedef signed int int32; -typedef unsigned int uint32; -#elif SIZEOF_LONG==4 -typedef signed long int32; -typedef unsigned long uint32; -#else -# error "No 32-bit integer type!" -#endif - -#if SIZEOF_SHORT!=2 -# error "Your short int data type is not 2 bytes: hopm (firedns) is not going to work for you." -#endif -]) AC_CONFIG_SUBDIRS(src/libopm) diff --git a/src/firedns.c b/src/firedns.c index fab8288..4516092 100644 --- a/src/firedns.c +++ b/src/firedns.c @@ -97,8 +97,8 @@ struct s_connection * firedns_add_query() */ unsigned char id[2]; - unsigned short class; - unsigned short type; + uint16_t class; + uint16_t type; /* file descriptor returned from sockets */ int fd; void *info; @@ -111,11 +111,11 @@ struct s_connection struct s_rr_middle { - unsigned short type; - unsigned short class; + uint16_t type; + uint16_t class; /* XXX - firedns depends on this being 4 bytes */ uint32 ttl; - unsigned short rdlength; + uint16_t rdlength; }; /* DNS query header */ @@ -135,10 +135,10 @@ struct s_header #define FLAGS2_MASK_Z 0x70 #define FLAGS2_MASK_RCODE 0x0f - unsigned short qdcount; - unsigned short ancount; - unsigned short nscount; - unsigned short arcount; + uint16_t qdcount; + uint16_t ancount; + uint16_t nscount; + uint16_t arcount; /* DNS question, populated by firedns_build_query_payload() */ unsigned char payload[512]; }; @@ -148,7 +148,7 @@ struct s_header static struct s_connection *firedns_add_query(void); static int firedns_doquery(struct s_connection *s); static int firedns_build_query_payload(const char * const name, - unsigned short rr, unsigned short class, unsigned char * payload); + uint16_t, uint16_t, unsigned char * payload); static int firedns_send_requests(struct s_header *h, struct s_connection *s, int l); @@ -386,11 +386,11 @@ static int firedns_doquery(struct s_connection *s) * populate payload with query: name= question, rr= record type */ static int firedns_build_query_payload(const char * const name, - unsigned short rr, unsigned short class, unsigned char * payload) + uint16_t rr, uint16_t class, unsigned char * payload) { - short payloadpos; + int16_t payloadpos; const char * tempchr, * tempchr2; - unsigned short l; + uint16_t l; payloadpos = 0; tempchr2 = name; diff --git a/src/setup.h.in b/src/setup.h.in index 9bc1139..72255ef 100644 --- a/src/setup.h.in +++ b/src/setup.h.in @@ -90,15 +90,6 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* The size of `int', as computed by sizeof. */ -#undef SIZEOF_INT - -/* The size of `long', as computed by sizeof. */ -#undef SIZEOF_LONG - -/* The size of `short', as computed by sizeof. */ -#undef SIZEOF_SHORT - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS @@ -129,19 +120,3 @@ /* Define to `unsigned int' if does not define. */ #undef size_t - - -#if SIZEOF_INT==4 -typedef signed int int32; -typedef unsigned int uint32; -#elif SIZEOF_LONG==4 -typedef signed long int32; -typedef unsigned long uint32; -#else -# error "No 32-bit integer type!" -#endif - -#if SIZEOF_SHORT!=2 -# error "Your short int data type is not 2 bytes: hopm (firedns) is not going to work for you." -#endif - -- 2.30.2