Hello.
On freebsd configure script incorrectly decides that system has
fmemopen() function (defines HAVE_FMEMOPEN 1). This happens because it
has AC_COMPILE_IFELSE directive for
int main(int argc, char *args[])
{ return fmemopen(args[0], 2, args[1]) == NULL; }
program.
It should be changed to AC_LINK_IFELSE, because compiler uses default
prototype for fmemopen() and compiles it. If we tried to link it, we
would have:
conftest.c: In function 'main':
conftest.c:9: warning: comparison between pointer and integer
/var/tmp//cclJD5PD.o(.text+0x3c): In function `main.2298':
: undefined reference to `fmemopen'
However, using AC_LINK_IFELSE is not enough, because ac_compile includes
"-O2" CFLAGS for gcc. It leads to incorrect behavior during linking:
(must be bug in gcc). When using -O2 switch, the program is compiled
only with warning:
conftest.c: In function 'main':
conftest.c:9: warning: comparison between pointer and integer
I'm making a freebsd port for fsvs and need advise, how to deal with
this? I would ask you to change AC_COMPILE_IFELSE to AC_LINK_IFELSE (it
seems more correct). For now in my port I will possibly use -O0 CFLAGS
to suppress this behavior, later I'll contact with (freebsd?) gcc
maintainers to report this bug.
Another bad feature of fsvs configure script is its "bashism". It uses
bash-specific (non-sh) test conditions:
[[ condition ]]should be changed to [ condition ],
&& should be changed to -a
== in shell should be changed to =.
It is not difficult, but makes program more sh-compliant.
Another point, ENODATA constant in src/est_ops.c should be changed to
APR_EOF. It makes this file portable.
Attaching patches to make fsvs more standard-compliant (they are not
enough to compile it on freebsd, but this is a minimum which will not
harm). Is there hope that this changes will be merged?
Also, on FreeBSD there is no alloca.h and fstat64, but I'll patch it in
port...
--
Best regards,
Alexander Pyhalov,
system administrator of Computer Center of South Federal University
------------------------------------------------------
http://fsvs.tigris.org/ds/viewMessage.do?dsForumId=3928&dsMessageId=2433578
To unsubscribe from this discussion, e-mail:
[[email protected]].
--- fsvs-1.2.1/configure.in 2009-09-24 12:22:45.000000000 +0400
+++ fsvs-1.2.1_patched/configure.in 2009-12-29 12:16:35.025272313 +0300
@@ -68,7 +68,7 @@
# We allow from 3 characters on, although it might not make
much
# sense.
WAA_WC_MD5_CHARS=`perl -e '$_=0+shift; print $_+0 if $_==0 ||
($_>3 && $_<=16)' "$withval"`
- if [[ "$WAA_WC_MD5_CHARS" == "" ]]
+ if [[ "$WAA_WC_MD5_CHARS" = "" ]]
then
AC_MSG_ERROR([[The given value for --with-waa_md5 is
invalid.]])
fi
@@ -222,7 +222,7 @@
fi
AC_SUBST(HAVE_O_DIRECTORY)
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[ #include <stdio.h> ]],
[[ int main(int argc, char *args[])
@@ -268,7 +268,7 @@
[])
AC_SUBST(ENABLE_RELEASE)
-if [[ "$ENABLE_RELEASE$ENABLE_DEBUG" == "11" ]]
+if [[ "$ENABLE_RELEASE$ENABLE_DEBUG" = "11" ]]
then
AC_MSG_ERROR([[--enable-debug and --enable-release are incompatibel.
Use one or the other.]])
@@ -292,7 +292,7 @@
AC_SUBST(HAS_FASTCALL)
# Only i386 (32bit) has fastcall.
-if [[ `uname -m` == i?86 ]]
+if [[ `uname -m` = i?86 ]]
then
HAS_FASTCALL=1
fi
@@ -300,7 +300,7 @@
AC_TYPE_UINT32_T
AC_SUBST(HAVE_UINT32_T)
# See config.h for an explanation.
-if [[ "$ac_cv_c_uint32_t" == "yes" ]]
+if [[ "$ac_cv_c_uint32_t" = "yes" ]]
then
ac_cv_c_uint32_t=uint32_t
fi
@@ -308,7 +308,7 @@
AC_TYPE_UINT64_T
AC_SUBST(HAVE_UINT64_T)
-if [[ "$ac_cv_c_uint64_t" == "yes" ]]
+if [[ "$ac_cv_c_uint64_t" = "yes" ]]
then
ac_cv_c_uint64_t=uint64_t
fi
@@ -335,8 +335,7 @@
# Cause a recompile
touch src/config.h
-if [ [[ "$ac_cv_header_linux_kdev_t_h" == "no" &&
- "x$ENABLE_DEV_FAKE" == "x" ]] ]
+if [ [ "$ac_cv_header_linux_kdev_t_h" = "no" -a "x$ENABLE_DEV_FAKE" = "x" ] ]
then
AC_MSG_WARN([
* MAJOR(), MINOR() and MAKEDEV() definitions not found.
--- fsvs-1.2.1/src/est_ops.c 2009-10-12 23:05:54.000000000 +0400
+++ fsvs-1.2.1_patched/src/est_ops.c 2009-12-28 13:02:00.043453670 +0300
@@ -1715,7 +1715,7 @@
/* Read data. */
len_read=special_len;
STOPIF( apr_file_read( a_stream, special_data, &len_read), NULL);
- STOPIF_CODE_ERR( len_read != special_len, ENODATA,
+ STOPIF_CODE_ERR( len_read != special_len, APR_EOF,
"Reading was cut off at byte %llu of %llu",
(t_ull)len_read, (t_ull)special_len);
special_data[len_read]=0;
--- fsvs-1.2.1/src/status.c 2009-10-12 23:05:54.000000000 +0400
+++ fsvs-1.2.1_patched/src/status.c 2009-12-28 13:04:08.633082993 +0300
@@ -786,8 +786,8 @@
STOPIF_CODE_EPIPE( printf(" Device nr.:\t%llu:%llu\n",
(t_ull)MAJOR(sts->st.rdev),
(t_ull)MINOR(sts->st.rdev)), NULL);
- }
#endif
+ }
else
STOPIF_CODE_EPIPE( printf(" Size: \t%llu\n",
(t_ull)sts->st.size), NULL);