Skip to content

Commit 2dc148e

Browse files
nick87720zlws-team
authored andcommitted
clean: remove needless LWS_PRE
Several examples trim their buffer with an extra LWS_PRE from the end... actually end should point to end the end of buf without a second LWS_PRE reservation. warmcat#2629
1 parent 43ba912 commit 2dc148e

File tree

8 files changed

+8
-8
lines changed

8 files changed

+8
-8
lines changed

minimal-examples-lowlevel/http-client/minimal-http-client-multi/minimal-http-client-multi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
167167
void *user, void *in, size_t len)
168168
{
169169
char buf[LWS_PRE + 1024], *start = &buf[LWS_PRE], *p = start,
170-
*end = &buf[sizeof(buf) - LWS_PRE - 1];
170+
*end = &buf[sizeof(buf) - 1];
171171
int n, idx = (int)(intptr_t)lws_get_opaque_user_data(wsi);
172172
struct pss *pss = (struct pss *)user;
173173

minimal-examples-lowlevel/http-client/minimal-http-client-post/minimal-http-client-post.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
3030
{
3131
struct pss *pss = (struct pss *)user;
3232
char buf[LWS_PRE + 1024], *start = &buf[LWS_PRE], *p = start,
33-
*end = &buf[sizeof(buf) - LWS_PRE - 1];
33+
*end = &buf[sizeof(buf) - 1];
3434
int n;
3535

3636
switch (reason) {

minimal-examples-lowlevel/http-server/minimal-http-server-custom-headers/minimal-http-server-custom-headers.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
3737
void *user, void *in, size_t len)
3838
{
3939
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
40-
*end = &buf[sizeof(buf) - LWS_PRE - 1];
40+
*end = &buf[sizeof(buf) - 1];
4141
struct pss *pss = (struct pss *)user;
4242
char value[32], *pr = &pss->result[LWS_PRE];
4343
size_t e = sizeof(pss->result) - LWS_PRE;

minimal-examples-lowlevel/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ callback_dynamic_http(struct lws *wsi, enum lws_callback_reasons reason,
4242
{
4343
struct pss *pss = (struct pss *)user;
4444
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
45-
*end = &buf[sizeof(buf) - LWS_PRE - 1];
45+
*end = &buf[sizeof(buf) - 1];
4646
time_t t;
4747
int n;
4848
#if defined(LWS_HAVE_CTIME_R)

minimal-examples-lowlevel/http-server/minimal-http-server-h2-long-poll/minimal-http-server.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
5757
struct pss * pss = (struct pss *)user;
5858
uint8_t buf[LWS_PRE + LWS_RECOMMENDED_MIN_HEADER_SPACE],
5959
*start = &buf[LWS_PRE], *p = start,
60-
*end = p + sizeof(buf) - LWS_PRE;
60+
*end = buf + sizeof(buf) - 1;
6161
int m, n;
6262

6363
switch (reason) {

plugins/acme-client/protocol_lws_acme_client.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ callback_chall_http01(struct lws *wsi, enum lws_callback_reasons reason,
136136
struct lws_vhost *vhost = lws_get_vhost(wsi);
137137
struct acme_connection *ac = lws_vhost_user(vhost);
138138
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
139-
*end = &buf[sizeof(buf) - LWS_PRE - 1];
139+
*end = &buf[sizeof(buf) - 1];
140140
int n;
141141

142142
switch (reason) {

plugins/deaddrop/protocol_lws_deaddrop.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ callback_deaddrop(struct lws *wsi, enum lws_callback_reasons reason,
383383
struct pss_deaddrop *pss = (struct pss_deaddrop *)user;
384384
uint8_t buf[LWS_PRE + LWS_RECOMMENDED_MIN_HEADER_SPACE],
385385
*start = &buf[LWS_PRE], *p = start,
386-
*end = &buf[sizeof(buf) - LWS_PRE - 1];
386+
*end = &buf[sizeof(buf) - 1];
387387
char fname[256], *wp;
388388
const char *cp;
389389
int n, m, was;

plugins/protocol_fulltext_demo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ callback_fts(struct lws *wsi, enum lws_callback_reasons reason, void *user,
6565
lws_get_protocol(wsi));
6666
struct pss_fts_demo *pss = (struct pss_fts_demo *)user;
6767
uint8_t buf[LWS_PRE + 2048], *start = &buf[LWS_PRE], *p = start,
68-
*end = &buf[sizeof(buf) - LWS_PRE - 1];
68+
*end = &buf[sizeof(buf) - 1];
6969
struct lws_fts_search_params params;
7070
const char *ccp = (const char *)in;
7171
struct lws_fts_result *result;

0 commit comments

Comments
 (0)