ithewei 3 år sedan
förälder
incheckning
28ef7d07b8
14 ändrade filer med 20 tillägg och 18 borttagningar
  1. 1 1
      CMakeLists.txt
  2. 1 1
      base/hbase.h
  3. 1 0
      base/hlog.c
  4. 3 3
      base/hmain.c
  5. 2 2
      base/hmain.h
  6. 1 0
      base/hplatform.h
  7. 1 1
      examples/hloop_test.c
  8. 1 1
      examples/nmap/main.cpp
  9. 1 1
      examples/nmap/nmap.cpp
  10. 1 1
      http/server/http_page.cpp
  11. 3 3
      http/wsdef.c
  12. 2 2
      misc/win32_getopt.h
  13. 1 1
      util/sha1.c
  14. 1 1
      util/sha1.h

+ 1 - 1
CMakeLists.txt

@@ -145,7 +145,7 @@ if(WITH_MBEDTLS)
 endif()
 
 if(WIN32)
-    add_definitions(-D_WIN32_WINNT=0x0600)
+    add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS -D_WIN32_WINNT=0x0600)
     set(LIBS ${LIBS} winmm iphlpapi ws2_32)
     if(ENABLE_WINDUMP)
         add_definitions(-DENABLE_WINDUMP)

+ 1 - 1
base/hbase.h

@@ -50,7 +50,7 @@ HV_EXPORT void  hv_free(void* ptr);
 
 HV_EXPORT long hv_alloc_cnt();
 HV_EXPORT long hv_free_cnt();
-HV_INLINE void hv_memcheck() {
+HV_INLINE void hv_memcheck(void) {
     printf("Memcheck => alloc:%ld free:%ld\n", hv_alloc_cnt(), hv_free_cnt());
 }
 #define HV_MEMCHECK    atexit(hv_memcheck);

+ 1 - 0
base/hlog.c

@@ -8,6 +8,7 @@
 
 //#include "hmutex.h"
 #ifdef _WIN32
+#pragma warning (disable: 4244) // conversion loss of data
 #include <windows.h>
 #define hmutex_t            CRITICAL_SECTION
 #define hmutex_init         InitializeCriticalSection

+ 3 - 3
base/hmain.c

@@ -169,7 +169,7 @@ int main_ctx_init(int argc, char** argv) {
     return 0;
 }
 
-void main_ctx_free() {
+void main_ctx_free(void) {
     if (g_main_ctx.save_argv) {
         SAFE_FREE(g_main_ctx.save_argv[0]);
         SAFE_FREE(g_main_ctx.save_argv);
@@ -377,7 +377,7 @@ int create_pidfile() {
     return 0;
 }
 
-void delete_pidfile() {
+void delete_pidfile(void) {
     hlogi("delete_pidfile('%s') pid=%d", g_main_ctx.pidfile, g_main_ctx.pid);
     remove(g_main_ctx.pidfile);
 }
@@ -508,7 +508,7 @@ static void WINAPI on_timer(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PT
     }
 }
 
-static void signal_cleanup() {
+static void signal_cleanup(void) {
     //CloseHandle(s_hEventTerm);
     //s_hEventTerm = NULL;
     CloseHandle(s_hEventReload);

+ 2 - 2
base/hmain.h

@@ -68,7 +68,7 @@ typedef struct option_s {
 } option_t;
 
 HV_EXPORT int  main_ctx_init(int argc, char** argv);
-HV_EXPORT void main_ctx_free();
+HV_EXPORT void main_ctx_free(void);
 
 // ls -a -l
 // ls -al
@@ -86,7 +86,7 @@ HV_EXPORT void setproctitle(const char* fmt, ...);
 
 // pidfile
 HV_EXPORT int   create_pidfile();
-HV_EXPORT void  delete_pidfile();
+HV_EXPORT void  delete_pidfile(void);
 HV_EXPORT pid_t getpid_from_pidfile();
 
 // signal=[start,stop,restart,status,reload]

+ 1 - 0
base/hplatform.h

@@ -110,6 +110,7 @@
 #pragma warning (disable: 4102) // unreferenced label
 #pragma warning (disable: 4244) // conversion loss of data
 #pragma warning (disable: 4251) // STL dll
+#pragma warning (disable: 4275) // dll-interface
 #pragma warning (disable: 4267) // size_t => int
 #pragma warning (disable: 4819) // Unicode
 #pragma warning (disable: 4996) // _CRT_SECURE_NO_WARNINGS

+ 1 - 1
examples/hloop_test.c

@@ -61,7 +61,7 @@ void on_stdin(hio_t* io, void* buf, int readbytes) {
 }
 
 void on_custom_events(hevent_t* ev) {
-    printf("on_custom_events event_type=%d userdata=%ld\n", (int)ev->event_type, (long)ev->userdata);
+    printf("on_custom_events event_type=%d userdata=%ld\n", (int)ev->event_type, (long)(intptr_t)ev->userdata);
 }
 
 int main() {

+ 1 - 1
examples/nmap/main.cpp

@@ -106,7 +106,7 @@ int main(int argc, char* argv[]) {
         }
     }
     // print up hosts
-    printf("Up hosts %lu:\n", up_hosts.size());
+    printf("Up hosts %lu:\n", (unsigned long)up_hosts.size());
     for (auto& host : up_hosts) {
         inet_ntop(AF_INET, (void*)&host, ip, sizeof(ip));
         printf("%s\n", ip);

+ 1 - 1
examples/nmap/nmap.cpp

@@ -136,7 +136,7 @@ int nmap_discover(Nmap* nmap) {
         ++iter;
     }
     printd("Nmap done: %lu IP addresses (%d hosts up) scanned in %.2f seconds\n",
-            nmap->size(), ctx.up_cnt, (end_hrtime-start_hrtime)/1000000.0f);
+            (unsigned long)nmap->size(), ctx.up_cnt, (end_hrtime-start_hrtime)/1000000.0f);
 
     return ctx.up_cnt;
 }

+ 1 - 1
http/server/http_page.cpp

@@ -54,7 +54,7 @@ void make_index_of_page(const char* dir, std::string& page, const char* url) {
     for (auto& item : dirs) {
         if (item.name[0] == '.' && item.name[1] == '\0') continue;
         page += "    <tr>\n";
-        int len = strlen(item.name) + (item.type == 'd');
+        size_t len = strlen(item.name) + (item.type == 'd');
         // name
         snprintf(c_str, sizeof(c_str), "<a href=\"%s%s\">%s%s</a>",
                 item.name,

+ 3 - 3
http/wsdef.c

@@ -13,8 +13,8 @@ void ws_encode_key(const char* key, char accept[]) {
     unsigned char digest[20] = {0};
     HV_SHA1_CTX ctx;
     HV_SHA1Init(&ctx);
-    HV_SHA1Update(&ctx, (unsigned char*)key, strlen(key));
-    HV_SHA1Update(&ctx, (unsigned char*)magic, strlen(magic));
+    HV_SHA1Update(&ctx, (unsigned char*)key, (uint32_t)strlen(key));
+    HV_SHA1Update(&ctx, (unsigned char*)magic, (uint32_t)strlen(magic));
     HV_SHA1Final(digest, &ctx);
     hv_base64_encode(digest, 20, accept);
 }
@@ -42,5 +42,5 @@ int ws_build_frame(
     int flags = opcode;
     if (fin) flags |= WS_FIN;
     if (has_mask) flags |=  WS_HAS_MASK;
-    return websocket_build_frame(out, (websocket_flags)flags, mask, data, data_len);
+    return (int)websocket_build_frame(out, (websocket_flags)flags, mask, data, data_len);
 }

+ 2 - 2
misc/win32_getopt.h

@@ -56,7 +56,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#pragma warning(disable:4996);
+#pragma warning(disable:4996)
 
 #define __GETOPT_H__
 
@@ -650,4 +650,4 @@ getopt_long_only(int nargc, char * const *nargv, const char *options,
 }
 #endif
 
-#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
+#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */

+ 1 - 1
util/sha1.c

@@ -277,7 +277,7 @@ void HV_SHA1Final(
 void HV_SHA1(
     char *hash_out,
     const char *str,
-    int len)
+    uint32_t len)
 {
     HV_SHA1_CTX ctx;
     unsigned int ii;

+ 1 - 1
util/sha1.h

@@ -43,7 +43,7 @@ HV_EXPORT void HV_SHA1Final(
 HV_EXPORT void HV_SHA1(
     char *hash_out,
     const char *str,
-    int len);
+    uint32_t len);
 
 HV_EXPORT void hv_sha1(unsigned char* input, uint32_t inputlen, unsigned char digest[20]);