Skip to content

Commit 1f08a5d

Browse files
committed
Fixed curl type warnings
- Removed unnecessary cruft in curl_utils.h
1 parent 433e43b commit 1f08a5d

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

src/host/curl_utils.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
#include <string.h>
1111

1212
#if LIBCURL_VERSION_NUM >= 0x072000
13-
int curlProgressCallback(curl_state* state, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
13+
int curlProgressCallback(void* stateptr, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
1414
#else
1515
int curlProgressCallback(curl_state* state, double dltotal, double dlnow, double ultotal, double ulnow)
1616
#endif
1717
{
18+
curl_state* state = ((curl_state*)stateptr);
1819
lua_State* L = state->L;
1920

2021
(void)ultotal;
@@ -90,9 +91,9 @@ CURL* curlRequest(lua_State* L, curl_state* state, int optionsIndex, int progres
9091
strcat(agent, PREMAKE_VERSION);
9192

9293
curl_easy_setopt(curl, CURLOPT_URL, luaL_checkstring(L, 1));
93-
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
94-
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
95-
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
94+
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
95+
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
96+
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
9697
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, state->errorBuffer);
9798
curl_easy_setopt(curl, CURLOPT_USERAGENT, agent);
9899

@@ -102,8 +103,8 @@ CURL* curlRequest(lua_State* L, curl_state* state, int optionsIndex, int progres
102103
lua_gettable(L, -2);
103104
if (!lua_isnil(L, -1))
104105
{
105-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
106-
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
106+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
107+
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
107108
}
108109
lua_pop(L, 2);
109110

@@ -184,7 +185,7 @@ CURL* curlRequest(lua_State* L, curl_state* state, int optionsIndex, int progres
184185

185186
if (state->L != 0)
186187
{
187-
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
188+
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
188189
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, state);
189190
#if LIBCURL_VERSION_NUM >= 0x072000
190191
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, curlProgressCallback);

src/host/curl_utils.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
#include <lua5.3/lua.h>
1616
#endif
1717

18-
#define _MPRINTF_REPLACE /* use curl functions only */
1918
#include <curl/curl.h>
20-
#include <curl/mprintf.h>
2119

2220
typedef struct
2321
{
@@ -28,14 +26,6 @@ typedef struct
2826
struct curl_slist* headers;
2927
} curl_state;
3028

31-
32-
#if LIBCURL_VERSION_NUM >= 0x072000
33-
int curlProgressCallback(curl_state* state, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
34-
#else
35-
int curlProgressCallback(curl_state* state, double dltotal, double dlnow, double ultotal, double ulnow);
36-
#endif
37-
size_t curlWriteCallback(char *ptr, size_t size, size_t nmemb, void* state);
38-
3929
CURL* curlRequest(lua_State* L, curl_state* state, int optionsIndex, int progressFnIndex, int headersIndex);
4030
void curlCleanup(CURL* curl, curl_state* state);
4131

src/host/http_download.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int http_download(lua_State* L)
4646

4747
if (curl)
4848
{
49-
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
49+
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
5050
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
5151
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_file_cb);
5252

src/host/http_get.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int http_get(lua_State* L)
3030

3131
if (curl)
3232
{
33-
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1);
33+
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
3434

3535
code = curl_easy_perform(curl);
3636
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode);

src/host/http_post.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ int http_post(lua_State* L)
2323
size_t dataSize;
2424
const char* data = luaL_checklstring(L, 2, &dataSize);
2525

26-
curl_easy_setopt(curl, CURLOPT_POST, 1);
26+
curl_easy_setopt(curl, CURLOPT_POST, 1L);
2727
if (data && dataSize > 0)
2828
{
2929
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)dataSize);

0 commit comments

Comments
 (0)