Skip to contentSkip to conversation

Fix build failure for discontiguous-io on 32-bit platforms

PATCH In review Theodore Ts'o 2 participants 4 messages Oct 30, 2018 – Oct 31, 2018 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix build failure for discontiguous-io on 32-bit platforms

---
 src/discontiguous-io.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/discontiguous-io.cpp +1 -1
index 5e0ee0f..f51a305 100644
@@ -251,7 +251,7 @@ int main(int argc, char **argv)
 	const char *dev;
 	int c;
 	std::vector<uint8_t> buf;
-	size_t len = 512;
+	unsigned long len = 512;
 
 	while ((c = getopt(argc, argv, "hl:o:sw")) != EOF) {
 		switch (c) {
Signature · 1 line
2.18.0.rc0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Theodore Ts'o

src/discontiguous-io.cpp |2 +--

1 file changed, 1 insertion(+-), 1 deletion(-)
src/discontiguous-io.cpp +1 -1
index 5e0ee0f..f51a305 100644
--- a/src/discontiguous-io.cpp
+-+-+- b/src/discontiguous-io.cpp

@@-251,7 +-251,7 @@int main(int argc, char **argv)

	const char *dev;> 	int c;> 	std::vector<uint8_t>buf;>-	size_t len =512;>+-	unsigned long len =512;> 
	while ((c =getopt(argc, argv, "hl:o:sw") !=EOF) {> 		switch (c) {

Details about how the build fails on 32-bit systems would have been welcome in the commit message. Anyway:

#2 lore raw
Quoted 4 lines · Bart Van Assche

Details about how the build fails on 32-bit systems would have been welcome in the commit message. Anyway:

For the record, here's the failure. It's the usual incomprehensible C++ error reporting. :-)

% schroot -c stretch-i386 -- ./build-all --blktests-only
----------------- 2018-10-30 16:00:18: Starting build of blktests
make -C src all
make[1]: Entering directory '/usr/projects/xfstests-bld/build-32/blktests/src'
g++ -O2 -std=c++11 -Wall -Wextra -Wno-sign-compare -Werror -o discontiguous-io discontiguous-io.cpp discontiguous-io.cpp: In function 'int main(int, char**)':
discontiguous-io.cpp:294:34: error: no matching function for call to 'min(long unsigned int, size_t)'

         std::min(4ul, len - i * 4));
                                  ^
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/iomanip:40,
                 from discontiguous-io.cpp:8:
/usr/include/c++/6/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
discontiguous-io.cpp:294:34: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'size_t {aka unsigned int}')
         std::min(4ul, len - i * 4));
                                  ^
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/string:40,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/iomanip:40,
                 from discontiguous-io.cpp:8:
/usr/include/c++/6/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/6/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
discontiguous-io.cpp:294:34: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'size_t {aka unsigned int}')
         std::min(4ul, len - i * 4));
                                  ^

Makefile:27: recipe for target 'discontiguous-io' failed
make[1]: *** [discontiguous-io] Error 1
make[1]: Leaving directory '/usr/projects/xfstests-bld/build-32/blktests/src' Makefile:2: recipe for target 'all' failed
make: *** [all] Error 2

#3 lore raw
Quoted 11 lines · Theodore Y. Ts'o
Quoted 4 lines · Bart Van Assche

Details about how the build fails on 32-bit systems would have been welcome in the commit message. Anyway:

For the record, here's the failure. It's the usual incomprehensible C+-+- error reporting. :-)

[... ]>discontiguous-io.cpp: In function 'int main(int, char**':
discontiguous-io.cpp:294:34: error: no matching function for call to 'min(long unsigned int, size_t)'

        std::min(4ul, len - i *4));>                                  ^>[... ]

Thanks Ted for having provided the full compiler output. However, I don't think that the entire error message should go in the commit message. To me, the part of the compiler error message I cited tells the whole story :-)

Bart.