mirror of https://github.com/getdnsapi/getdns.git
Deal with Windows vsnprintf behaviour
+ a better situated DEBUG_STUB statement in getdns_query
This commit is contained in:
parent
6d7645705a
commit
a970dd420f
|
@ -120,8 +120,8 @@ gldns_buffer_printf(gldns_buffer *buffer, const char *format, ...)
|
|||
|
||||
remaining = gldns_buffer_remaining(buffer);
|
||||
va_start(args, format);
|
||||
written = vsnprintf((char *) gldns_buffer_current(buffer), remaining,
|
||||
format, args);
|
||||
written = _gldns_vsnprintf((char*)gldns_buffer_current(buffer),
|
||||
remaining, format, args);
|
||||
va_end(args);
|
||||
if (written == -1) {
|
||||
buffer->_status_err = 1;
|
||||
|
@ -132,7 +132,8 @@ gldns_buffer_printf(gldns_buffer *buffer, const char *format, ...)
|
|||
return -1;
|
||||
}
|
||||
va_start(args, format);
|
||||
written = vsnprintf((char *) gldns_buffer_current(buffer),
|
||||
written = _gldns_vsnprintf(
|
||||
(char *) gldns_buffer_current(buffer),
|
||||
gldns_buffer_remaining(buffer), format, args);
|
||||
va_end(args);
|
||||
if (written == -1) {
|
||||
|
|
|
@ -27,6 +27,21 @@ extern "C" {
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef USE_WINSOCK
|
||||
#define _gldns_vsnprintf vsnprintf
|
||||
#else
|
||||
/* Unlike Linux and BSD, vsnprintf on Windows returns -1 on overflow.
|
||||
* Here it is redefined to always return the amount printed
|
||||
* if enough space had been available.
|
||||
*/
|
||||
INLINE int
|
||||
_gldns_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
||||
{
|
||||
int r = vsnprintf(str, size, format, ap);
|
||||
return r == -1 ? _vscprintf(format, ap) : r;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copy data allowing for unaligned accesses in network byte order
|
||||
* (big endian).
|
||||
|
|
|
@ -278,7 +278,7 @@ int gldns_wire2str_dname_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
|
|||
|
||||
int gldns_str_vprint(char** str, size_t* slen, const char* format, va_list args)
|
||||
{
|
||||
int w = vsnprintf(*str, *slen, format, args);
|
||||
int w = _gldns_vsnprintf(*str, *slen, format, args);
|
||||
if(w < 0) {
|
||||
/* error in printout */
|
||||
return 0;
|
||||
|
|
|
@ -68,12 +68,13 @@ my_eventloop_schedule(getdns_eventloop *loop,
|
|||
my_eventloop *my_loop = (my_eventloop *)loop;
|
||||
size_t i;
|
||||
|
||||
DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p, FD_SETSIZE: %d)\n"
|
||||
, __FUNCTION__, loop, fd, timeout, event, FD_SETSIZE);
|
||||
|
||||
assert(loop);
|
||||
assert(event);
|
||||
assert(fd < FD_SETSIZE);
|
||||
|
||||
DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p)\n"
|
||||
, __FUNCTION__, loop, fd, timeout, event);
|
||||
if (fd >= 0 && (event->read_cb || event->write_cb)) {
|
||||
assert(my_loop->fd_events[fd] == NULL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue