Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it compile on Musl and fix warnings #35

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

filoozom
Copy link
Contributor

@filoozom filoozom commented Dec 26, 2017

  • Make it compile on Musl
    Not quite sure that #if !defined(__linux__) || defined(__GLIBC__) (in strlcpy.h) is the best way to do it, but it works.

  • Fix warnings: C++11 requires a space between literal and string macro
    Basically this code for XXXXX = { PRI64d, PRIszu, PRI64u, PRI64x, PRIpdd }:

find . -type f -exec sed -i 's/"XXXXX/" XXXXX/g' {} \;
find . -type f -exec sed -i 's/XXXXX"/XXXXX "/g' {} \;
  • Include fcntl.h instead of sys/fcntl.h
    fcntl.h was already used in leveldb/util/env_posix.cc and leveldb/db/corruption_test.cc and sys/fcntl.h throws a warning.

  • Remove two unused variables
    Those variables weren't used in the code or in some comments, so I removed them instead of commenting them out.

  • Fix wrong formats
    %u for CTransaction.nTime, %PRI64d for GetBlockTime().

  • Fix misleading indentation

  • Use unique_ptr instead of auto_ptr
    auto_ptr is deprecated.

  • Add default return in exp_n2
    Doesn't change the return value but fixes the following warning:

In file included from hash_magi.h:5:0,
                 from main.h:13,
                 from db.h:8,
                 from main.cpp:8:
magimath.h: In function 'double exp_n2(double, double)':
magimath.h:46:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
  • Dynamically allocate x and w in GaussianQuad_N
    Fix the following warning:
magimath.cpp: In function 'double GaussianQuad_N(double (*)(double), double, double, int)':
magimath.cpp:46:8: warning: stack protector not protecting local variables: variable length buffer [-Wstack-protector]
 double GaussianQuad_N(double func(const double), const double a2, const double b2, const int NptGQ)
        ^~~~~~~~~~~~~~
  • Explicitely cast subscript to int in util.cpp
    Fix the following warning:
util.cpp: In function 'long int hex2long(const char*)':
util.cpp:503:43: warning: array subscript has type 'char' [-Wchar-subscripts]
   ret = (ret << 4) | hextable[*hexString++];
                                           ^
  • Assign default value to nPos in GetClientVersion
    Fix the following warning:
util.cpp: In function 'unsigned int GetClientVersion(int, std::__cxx11::string)':
util.cpp:1399:50: warning: 'nPos' may be used uninitialized in this function [-Wmaybe-uninitialized]
     unsigned int nVersion = nClientVersion * 10, nPos;
                                                  ^~~~

@filoozom filoozom changed the title Make it compile on Musl Make it compile on Musl and fix warnings Dec 26, 2017
Copy link

@ovpn-to ovpn-to left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work!

this commit throwing error:
16c7511

tested @ debian 9 stretch x64

make -f makefile.unix
/bin/sh ../share/genbuild.sh obj/build.h
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE -I/mnt/gits/eqcore/src -I/mnt/gits/eqcore/src/hash -I/mnt/gits/eqcore/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 -I/mnt/gits/eqcore/src/leveldb/include -I/mnt/gits/eqcore/src/leveldb/helpers -DHAVE_BUILD_INFO -fno-stack-protector -fstack-protector-all -Wstack-protector -D_FORTIFY_SOURCE=2 -msse2 -MMD -MF obj/netbase.d -o obj/netbase.o netbase.cpp
In file included from netbase.cpp:15:0:
strlcpy.h:16:0: error: unterminated #ifndef
#ifndef BITCOIN_STRLCPY_H

makefile.unix:186: recipe for target 'obj/netbase.o' failed
make: *** [obj/netbase.o] Error 1

@filoozom filoozom mentioned this pull request Jan 5, 2018
@filoozom
Copy link
Contributor Author

filoozom commented Jan 5, 2018

Did you apply this commit too: b0264b0? Should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants