Skip to content

Commit decd3ba

Browse files
committed
Fix broken build
1 parent 0f03ad8 commit decd3ba

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

ngx_http_tnt_module.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <ngx_core.h>
77
#include <ngx_http.h>
88

9-
#include <tp.h>
109
#include <tp_transcode.h>
1110

1211

tp_transcode.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
#include <inttypes.h>
33
#include <stdio.h>
44

5-
65
#define MP_SOURCE 1
7-
86
#include "tp.h"
97
#include "tp_transcode.h"
108

@@ -37,8 +35,8 @@ while (0)
3735
typedef struct {
3836
char *ptr;
3937
int16_t count;
40-
#define TYPE_MAP 1
41-
#define TYPE_ARRAY 2
38+
#define TYPE_MAP 1
39+
#define TYPE_ARRAY 2
4240
int type;
4341
} stack_item_t;
4442

@@ -459,7 +457,7 @@ yajl_json2tp_transcode(void *ctx, const char *input, size_t input_size)
459457
if (mp_unlikely(stat != yajl_status_ok)) {
460458

461459
if (!s_ctx->tc->errmsg[0]) {
462-
unsigned char *err;
460+
unsigned char *err;
463461
stat = yajl_complete_parse(s_ctx->hand);
464462
err = yajl_get_error(s_ctx->hand, 0, input_, input_size);
465463
say_error(s_ctx, "%s", err);
@@ -857,3 +855,18 @@ tp_transcode_init(tp_transcode_t *t, char *output, size_t output_size,
857855

858856
return TP_TRANSCODE_OK;
859857
}
858+
859+
ssize_t
860+
tp_read_payload(const char * const buf, const char * const end)
861+
{
862+
const size_t size = end - buf;
863+
if (size == 0 || size < 6)
864+
return 0;
865+
const char *p = buf, *test = buf;
866+
if (mp_check(&test, buf + size))
867+
return -1;
868+
if (mp_typeof(*p) != MP_UINT)
869+
return -1;
870+
return mp_decode_uint(&p) + p - buf;
871+
}
872+

tp_transcode.h

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
extern "C" {
66
#endif
77

8+
89
/* {{{ API declaration */
910
struct tp_transcode;
1011

@@ -67,6 +68,9 @@ typedef struct tp_transcode {
6768
#define TP_TRANSCODE_ERROR 2
6869
#define TP_TRANSCODE_AGAIN 3
6970

71+
ssize_t
72+
tp_read_payload(const char * const buf, const char * const end);
73+
7074
/**
7175
* Initialize struct tp_transcode.
7276
* Returns TP_TRANSCODE_ERROR if codec not found or create codec failed
@@ -102,7 +106,7 @@ tp_dump(char *output, size_t output_size, char *input, size_t input_size);
102106
static inline int
103107
tp_transcode_complete(tp_transcode_t *t, size_t *complete_msg_size)
104108
{
105-
if (mp_likely(t != NULL)) {
109+
if (t != NULL) {
106110
const int rc = t->codec.complete(t->codec.ctx, complete_msg_size);
107111
t->codec.free(t->codec.ctx);
108112
return rc;
@@ -113,7 +117,7 @@ tp_transcode_complete(tp_transcode_t *t, size_t *complete_msg_size)
113117
static inline int
114118
tp_transcode(tp_transcode_t *t, char *b, size_t size)
115119
{
116-
if (mp_likely(t != NULL))
120+
if (t != NULL)
117121
return t->codec.transcode(t->codec.ctx, b, size);
118122
return TP_TRANSCODE_ERROR;
119123
}
@@ -123,11 +127,11 @@ tp_dump(char *output, size_t output_size, char *input, size_t input_size)
123127
{
124128
tp_transcode_t t;
125129
if (tp_transcode_init(&t, output, output_size, TP_TO_JSON)
126-
== TP_TRANSCODE_ERROR)
130+
== TP_TRANSCODE_ERROR)
127131
return false;
128132

129133
if (tp_transcode(&t, input, input_size) == TP_TRANSCODE_ERROR)
130-
return false;
134+
return false;
131135

132136
size_t complete_msg_size = 0;
133137
tp_transcode_complete(&t, &complete_msg_size);
@@ -136,21 +140,6 @@ tp_dump(char *output, size_t output_size, char *input, size_t input_size)
136140
return complete_msg_size > 0;
137141
}
138142

139-
static inline ssize_t
140-
tp_read_payload(const char * const buf, const char * const end)
141-
{
142-
const size_t size = end - buf;
143-
if (size == 0 || size < 6)
144-
return 0;
145-
const char *p = buf, *test = buf;
146-
memset(r, 0, sizeof(struct tpresponse));
147-
if (mp_check(&test, buf + size))
148-
return -1;
149-
if (mp_typeof(*p) != MP_UINT)
150-
return -1;
151-
return mp_decode_uint(&p) + p - buf;
152-
}
153-
154143
#ifdef __cplusplus
155144
} /* extern "C" */
156145
#endif

0 commit comments

Comments
 (0)