Fix minor warnings and documentation typos (#666)

Build warnings could be seen [here](https://buildd.debian.org/status/fetch.php?pkg=c-ares&arch=arm64&ver=1.24.0-1&stamp=1702826366&raw=0) [origin](https://buildd.debian.org/status/package.php?p=c-ares)

Fix By: Gregor Jasny (@gjasny)
pull/669/head
Gregor Jasny 12 months ago committed by GitHub
parent 7aa6763641
commit 78b61327fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      INSTALL.md
  2. 2
      README.md
  3. 2
      src/lib/ares__htable.c
  4. 2
      test/ares-test-internal.cc
  5. 4
      test/ares-test-misc.cc
  6. 10
      test/ares-test.cc
  7. 4
      test/dns-proto.cc

@ -32,7 +32,7 @@ the same for both Git and official release tarballs.
AutoTools Build AutoTools Build
=============== ===============
### General Information, works on most Unix Platforms (Linux, FreeBSD, etc) ### General Information, works on most Unix Platforms (Linux, FreeBSD, etc.)
A normal Unix installation is made in three or four steps (after you've A normal Unix installation is made in three or four steps (after you've
unpacked the source archive): unpacked the source archive):
@ -57,7 +57,7 @@ you need to specify that already when running configure:
If you happen to have write permission in that directory, you can do `make If you happen to have write permission in that directory, you can do `make
install` without being root. An example of this would be to make a local install` without being root. An example of this would be to make a local
install in your own home directory: installation in your own home directory:
./configure --prefix=$HOME ./configure --prefix=$HOME
make make
@ -183,7 +183,7 @@ Method using a configure cross-compile (tested with Android NDK r7b):
./tools/make-standalone-toolchain.sh ./tools/make-standalone-toolchain.sh
which creates a usual cross-compile toolchain. Lets assume that you put which creates a usual cross-compile toolchain. Let's assume that you put
this toolchain below `/opt` then invoke configure with something this toolchain below `/opt` then invoke configure with something
like: like:
@ -213,7 +213,7 @@ CMake builds
============ ============
Current releases of c-ares introduce a CMake v3+ build system that has been Current releases of c-ares introduce a CMake v3+ build system that has been
tested on most platforms including Windows, Linux, FreeBSD, MacOS, AIX and tested on most platforms including Windows, Linux, FreeBSD, macOS, AIX and
Solaris. Solaris.
In the most basic form, building with CMake might look like: In the most basic form, building with CMake might look like:
@ -233,12 +233,17 @@ Options
Options to CMake are passed on the command line using "-D${OPTION}=${VALUE}". Options to CMake are passed on the command line using "-D${OPTION}=${VALUE}".
The values defined are all boolean and take values like On, Off, True, False. The values defined are all boolean and take values like On, Off, True, False.
* CARES_STATIC - Build the static library (off by default) | Option Name | Description | Default Value |
* CARES_SHARED - Build the shared library (on by default) |-----------------------------|-----------------------------------------------------------------------|----------------|
* CARES_INSTALL - Hook in installation, useful to disable if chain building | CARES_STATIC | Build the static library | Off |
* CARES_STATIC_PIC - Build the static library as position-independent (off by | CARES_SHARED | Build the shared library | On |
default) | CARES_INSTALL | Hook in installation, useful to disable if chain building | On |
| CARES_STATIC_PIC | Build the static library as position-independent | Off |
| CARES_BUILD_TESTS | Build and run tests | Off |
| CARES_BUILD_CONTAINER_TESTS | Build and run container tests (implies CARES_BUILD_TESTS, Linux only) | Off |
| CARES_BUILD_TOOLS | Build tools | On |
| CARES_SYMBOL_HIDING | Hide private symbols in shared libraries | Off |
| CARES_THREADS | Build with thread-safety support | On |
Ninja Ninja
----- -----

@ -49,7 +49,7 @@ Notes for c-ares hackers
* If you intend to distribute an already compiled c-ares library you **MUST** * If you intend to distribute an already compiled c-ares library you **MUST**
also distribute along with it the generated `ares_build.h` which has been also distribute along with it the generated `ares_build.h` which has been
used to compile it. Otherwise the library will be of no use for the users of used to compile it. Otherwise, the library will be of no use for the users of
the library that you have built. It is **your** responsibility to provide this the library that you have built. It is **your** responsibility to provide this
file. No one at the c-ares project can know how you have built the library. file. No one at the c-ares project can know how you have built the library.

@ -46,7 +46,7 @@ struct ares__htable {
* hash collisions we would have O(log n) worst case insert and search * hash collisions we would have O(log n) worst case insert and search
* performance. (We'd also need to make key_eq into a key_cmp to * performance. (We'd also need to make key_eq into a key_cmp to
* support sort). That said, risk with a random hash seed is near zero, * support sort). That said, risk with a random hash seed is near zero,
* and ares__slist_t is heavier weight so I think using ares__llist_t is * and ares__slist_t is heavier weight, so I think using ares__llist_t
* is an overall win. */ * is an overall win. */
ares__llist_t **buckets; ares__llist_t **buckets;
}; };

@ -235,7 +235,7 @@ TEST_F(LibraryTest, FreeCorruptData) {
void* p = &(data->data); void* p = &(data->data);
// Invalid type // Invalid type
data->type = (ares_datatype)99; data->type = (ares_datatype)ARES_DATATYPE_LAST;
data->mark = ARES_DATATYPE_MARK; data->mark = ARES_DATATYPE_MARK;
ares_free_data(p); ares_free_data(p);

@ -351,8 +351,8 @@ TEST_F(DefaultChannelTest, SendFailure) {
EXPECT_EQ(ARES_EBADQUERY, result.status_); EXPECT_EQ(ARES_EBADQUERY, result.status_);
} }
std::string ExpandName(const std::vector<byte>& data, int offset, static std::string ExpandName(const std::vector<byte>& data, int offset,
long *enclen) { long *enclen) {
char *name = nullptr; char *name = nullptr;
int rc = ares_expand_name(data.data() + offset, data.data(), (int)data.size(), int rc = ares_expand_name(data.data() + offset, data.data(), (int)data.size(),
&name, enclen); &name, enclen);

10
test/ares-test.cc vendored

@ -376,8 +376,8 @@ void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr,
<< ")" << std::endl; << ")" << std::endl;
return; return;
} }
byte* question = data + 12; byte* question = data + NS_HFIXEDSZ;
int qlen = len - 12; int qlen = len - NS_HFIXEDSZ;
char *name = nullptr; char *name = nullptr;
long enclen; long enclen;
@ -386,7 +386,11 @@ void MockServer::ProcessPacket(ares_socket_t fd, struct sockaddr_storage *addr,
std::cerr << "Failed to retrieve name" << std::endl; std::cerr << "Failed to retrieve name" << std::endl;
return; return;
} }
qlen -= enclen; if (enclen > qlen) {
std::cerr << "(error, encoded name len " << enclen << "bigger than remaining data " << qlen << " bytes)" << std::endl;
return;
}
qlen -= (int)enclen;
question += enclen; question += enclen;
std::string namestr(name); std::string namestr(name);
ares_free_string(name); ares_free_string(name);

4
test/dns-proto.cc vendored

@ -270,7 +270,7 @@ std::string QuestionToString(const std::vector<byte>& packet,
ss << "(error, encoded name len " << enclen << "bigger than remaining data " << *len << " bytes)"; ss << "(error, encoded name len " << enclen << "bigger than remaining data " << *len << " bytes)";
return ss.str(); return ss.str();
} }
*len -= enclen; *len -= (int)enclen;
*data += enclen; *data += enclen;
ss << "'" << name << "' "; ss << "'" << name << "' ";
ares_free_string(name); ares_free_string(name);
@ -306,7 +306,7 @@ std::string RRToString(const std::vector<byte>& packet,
ss << "(error, encoded name len " << enclen << "bigger than remaining data " << *len << " bytes)"; ss << "(error, encoded name len " << enclen << "bigger than remaining data " << *len << " bytes)";
return ss.str(); return ss.str();
} }
*len -= enclen; *len -= (int)enclen;
*data += enclen; *data += enclen;
ss << "'" << name << "' "; ss << "'" << name << "' ";
ares_free_string(name); ares_free_string(name);

Loading…
Cancel
Save