deps,src: align ssize_t ABI between Node & nghttp2
Previously, we performed casts that are considered undefined behavior. Instead, just define `ssize_t` for nghttp2 the same way we define it for the rest of Node. Also, remove a TODO comment that would probably also be *technically* correct but shouldn’t matter as long as nobody is complaining. PR-URL: https://github.com/nodejs/node/pull/18565 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
180af17b52
commit
93bbe4e3ee
14
deps/nghttp2/lib/includes/config.h
vendored
14
deps/nghttp2/lib/includes/config.h
vendored
@ -1,8 +1,18 @@
|
|||||||
/* Hint to the compiler that a function never returns */
|
/* Hint to the compiler that a function never returns */
|
||||||
#define NGHTTP2_NORETURN
|
#define NGHTTP2_NORETURN
|
||||||
|
|
||||||
/* Define to `int' if <sys/types.h> does not define. */
|
/* Edited to match src/node.h. */
|
||||||
#define ssize_t int
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
|
||||||
|
typedef intptr_t ssize_t;
|
||||||
|
# define _SSIZE_T_
|
||||||
|
# define _SSIZE_T_DEFINED
|
||||||
|
#endif
|
||||||
|
#else // !_WIN32
|
||||||
|
# include <sys/types.h> // size_t, ssize_t
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
/* Define to 1 if you have the `std::map::emplace`. */
|
/* Define to 1 if you have the `std::map::emplace`. */
|
||||||
#define HAVE_STD_MAP_EMPLACE 1
|
#define HAVE_STD_MAP_EMPLACE 1
|
||||||
|
@ -184,7 +184,6 @@ NODE_EXTERN v8::Local<v8::Value> MakeCallback(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// TODO(tjfontaine) consider changing the usage of ssize_t to ptrdiff_t
|
|
||||||
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
|
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
|
||||||
typedef intptr_t ssize_t;
|
typedef intptr_t ssize_t;
|
||||||
# define _SSIZE_T_
|
# define _SSIZE_T_
|
||||||
|
@ -764,13 +764,7 @@ inline ssize_t Http2Session::Write(const uv_buf_t* bufs, size_t nbufs) {
|
|||||||
bufs[n].len);
|
bufs[n].len);
|
||||||
CHECK_NE(ret, NGHTTP2_ERR_NOMEM);
|
CHECK_NE(ret, NGHTTP2_ERR_NOMEM);
|
||||||
|
|
||||||
// If there is an error calling any of the callbacks, ret will be a
|
if (ret < 0)
|
||||||
// negative number identifying the error code. This can happen, for
|
|
||||||
// instance, if the session is destroyed during any of the JS callbacks
|
|
||||||
// Note: if ssize_t is not defined (e.g. on Win32), nghttp2 will typedef
|
|
||||||
// ssize_t to int. Cast here so that the < 0 check actually works on
|
|
||||||
// Windows.
|
|
||||||
if (static_cast<int>(ret) < 0)
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
total += ret;
|
total += ret;
|
||||||
@ -1709,10 +1703,7 @@ void Http2Session::OnStreamRead(ssize_t nread, const uv_buf_t& buf) {
|
|||||||
statistics_.data_received += nread;
|
statistics_.data_received += nread;
|
||||||
ssize_t ret = Write(&stream_buf_, 1);
|
ssize_t ret = Write(&stream_buf_, 1);
|
||||||
|
|
||||||
// Note: if ssize_t is not defined (e.g. on Win32), nghttp2 will typedef
|
if (ret < 0) {
|
||||||
// ssize_t to int. Cast here so that the < 0 check actually works on
|
|
||||||
// Windows.
|
|
||||||
if (static_cast<int>(ret) < 0) {
|
|
||||||
DEBUG_HTTP2SESSION2(this, "fatal error receiving data: %d", ret);
|
DEBUG_HTTP2SESSION2(this, "fatal error receiving data: %d", ret);
|
||||||
|
|
||||||
Local<Value> argv[] = {
|
Local<Value> argv[] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user