1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-12-22 04:02:04 +03:00
Commit Graph

2380 Commits

Author SHA1 Message Date
bel
3c810102d1 Compile Warnings for Visual Studio (#132) 2015-05-22 17:39:28 +02:00
bel2125
da42c746b0 Merge pull request #133 from vcatechnology/mingw-fixes
MinGW Fixes
2015-05-22 17:32:18 +02:00
Matt Clarkson
81b43e9450 Correct the dialog callbacks
The dialog callback type actually returns INT_PTR even though it returns
a boolean value.

MSDN has the following to say:

> Type: INT_PTR
>
> Typically, the dialog box procedure should return TRUE if it
> processed the message, and FALSE if it did not. If the dialog box
> procedure returns FALSE, the dialog manager performs the default
> dialog operation in repsonse to the message.

Top work Microsoft!
2015-05-22 16:19:40 +01:00
Matt Clarkson
a35cd511fa Correct argument for GetDlgItem
GetDlgItem takes an integer as the identifier of the contol to be
retrieved. buflen is an unsigned integer. Assuming this code works
this just makes the truncation cast explicit. No functionality changes
but buflen *could* be over the limit of an integer. Very unlikey that
there will be a string that is 2^31 long though.
2015-05-22 16:19:40 +01:00
Matt Clarkson
798e808e2b Cast the process id
GetProcessId returns a DWORD (which is unsigned) and the HighPart or a
LARGE_INTEGER is a LONG (which is signed). As we are just doing some
hashing it is fine to cast this.
2015-05-22 16:19:40 +01:00
Matt Clarkson
d81258ce88 Use correct type for pointer alignment
On 64bit systems casting to long may result in a truncation of data
resulting in an incorrect alignment
2015-05-22 16:19:40 +01:00
Matt Clarkson
d8f7976560 add_control uses same types as DLGITEMTEMPLATE
This resolves a lot of sign conversion warnings and avoids hidden
truncation casting inside the function.
2015-05-22 16:19:40 +01:00
Matt Clarkson
05b78cf925 Correct casting of pointers
Casting pointers to intgers for arithmetic should be done with intptr_t
as that is corrected for pointer widths on 32bit and 64bit systems
2015-05-22 16:19:40 +01:00
Matt Clarkson
a13cd6e0dd Hide unused function
The create_config_file is not currently used on Windows.
2015-05-22 16:19:40 +01:00
Matt Clarkson
e724d36c28 Cast the unsigned constant
ioctlsocket cmd takes a long but FIONBIO can be declared as an unsigned
integer. We cast to avoid sign conversion warnings.
2015-05-22 16:19:40 +01:00
Matt Clarkson
fbcb2f9e71 Make the set_close_on_exec shim cross-platform
The declartion of the set_close_on_exec function has different
signatures on Windows and non-Windows platforms. This makes them
the same. Solves some casting issues.
2015-05-22 16:19:40 +01:00
Matt Clarkson
4ce8508133 Cast len to unsigned
On Windows the length to getnameinfo is a DWORD and socklen_t is an
integer. This results in sign conversion. On POSIX socklen_t is an
unsigned integer. Let's cast to unsigned to make both sides happy.
2015-05-22 16:18:56 +01:00
Matt Clarkson
7ca7be219a Do time period calculation in int64_t
Resolves casting issues.
2015-05-22 16:06:20 +01:00
Matt Clarkson
379a25e7c1 Correctly cast in Windows kill shim 2015-05-22 16:06:19 +01:00
Matt Clarkson
bc7891f8da Cast pointers with uintptr_t
Casting pointers to usigned int can result in truncations. uintptr_t is
the correct type to cast to when doing pointer arithmetic
2015-05-22 16:06:19 +01:00
Matt Clarkson
9a160dd4dd Simplify error number printing
Can put the value straight into the DEBUG_TRACE
2015-05-22 16:06:19 +01:00
Matt Clarkson
4941f78b95 Cast the milliseconds to DWORD
The milliseconds must be cast to the unsigned DWORD value
2015-05-22 16:06:19 +01:00
Matt Clarkson
05f3bf9d5a in_addr_t not available on windows
We could #define it but uint32_t is more explicit anyway
2015-05-22 16:06:14 +01:00
Matt Clarkson
91aaf0894d errno is an integer
The ERRNO shim should provide errno as an int. GetLastError() on
Windows results in a DWORD (undigned int).
2015-05-22 16:06:14 +01:00
Matt Clarkson
d3e3a9c723 poll takes unsigned int
The poll shim should take an unsigned int as the posix function does
for the number of file descriptors.
2015-05-22 16:06:14 +01:00
Matt Clarkson
9b544d184b Remove unused pthread functions
We shim the POSIX thread functionality for windows but don't use all
of the functions. This hides them behind ENABLE_USED_POSIX_FUNCTIONS
so that they can still exit if someone needs them in the future.
2015-05-22 16:06:14 +01:00
Matt Clarkson
da57b9e811 Remove redundant break
The die function is noreturn so will exit the program
2015-05-22 16:06:06 +01:00
Matt Clarkson
faee7ad229 Correct tag non-returning functions
The noreturn attribute can be used to allow the compiler to perform
better optimisations and/or warnings.
2015-05-22 16:06:06 +01:00
Matt Clarkson
5cf0b41576 Cannot do ntohl on a 64bit long
The code is attempting to reverse the byte order of a long which is
64bits on 64bit systems. This isn't possible so we should do the
conversion before the memory copy.
2015-05-22 16:06:06 +01:00
Matt Clarkson
5d8291ca9c Cast the length to socklen_t
socklen_t usually unsigned int where as size_t is unsigned long on
64bit
2015-05-22 16:06:06 +01:00
Matt Clarkson
40dc5c6d81 Variable abs shadows on gcc 4.6.3
Just make it a more explicit variable name, absolute
2015-05-22 16:06:06 +01:00
Matt Clarkson
2feecee701 Pointer alignment is acceptable
The h_addr_list is an array of pointers to network addresses for the host
in network byte order and it terminated by a null pointer. It is safe to
cast the address to a in_addr (which is effectively a uint32_t). However
we must cast it though void* to tell the compiler that we are OK with
the 1 byte alignment of the char pointer to a uint32_t pointer.
2015-05-22 16:05:52 +01:00
Matt Clarkson
175c0ce9dd Set SSL boolean with value rather than int
Shortening an integer to an unsigned char can lead to a situation where the
bottom 8 bits of the integer are all zeroes but the integer is actually
truthy. Using a ternary operator removes the ambiguity and solves compiler
warnings
2015-05-22 16:05:51 +01:00
Matt Clarkson
e0948d0d98 Prevent sign conversion
We must convert the result of the unsigned subtraction to signed to
avoid compiler warnings.
2015-05-22 16:05:51 +01:00
Matt Clarkson
f436702700 index variable shadows in gcc 4.6.3 2015-05-22 16:05:51 +01:00
Dialga
b84609a6dd Merge remote-tracking branch 'upstream/master' 2015-05-22 11:12:58 +12:00
bel
13a6b935aa Avoid the missing-prototypes warning
Warning option -Wmissing-prototypes raises a warning for all functions
that are neither static nor in a header. Some functions should be available
only for main.c but not in the official header (civetweb.h) since they are
subject to changes. In order to avoid this warning, additional headers
outside the include folder must be added.
2015-05-22 00:08:40 +02:00
bel
10372ce328 Autoformat *.inl 2015-05-21 23:15:10 +02:00
bel
d51c38a5cb Fix some warnings 2015-05-21 23:14:56 +02:00
bel2125
2ceaaa708e Remove -Wsign-conversion for the moment
This warning option causes a flood of warnings in third party components,
so other warnings are no longer visible in the many pages of warnings.
For the moment remove this option again.
Later it could be activated for CivetWeb without the third_party folder.
2015-05-21 22:50:00 +02:00
bel
1b730992c9 Fix some gcc warnings 2015-05-21 22:45:33 +02:00
bel2125
2a5cb9ed6c Merge Linux Makefile warning options 2015-05-21 22:28:37 +02:00
bel2125
e994488947 Merge pull request #130 from hansipie/master
assert if pointer is NULL
2015-05-21 22:26:10 +02:00
hansipie
59c418cd01 minor fix 2015-05-21 21:44:29 +02:00
hansipie
8c971d1296 check pointer value
Check if the pointer is NULL
2015-05-21 21:38:21 +02:00
bel
bd377322e5 Init endptr argument of strtol and autoformat 2015-05-21 21:30:09 +02:00
bel
b83ebccb0e Autoformat after merge (no code change) 2015-05-21 21:21:54 +02:00
Matt Clarkson
49fa91ea8b Make private function private in server executable
Functions either need to be exported or static. As this is going to
be built into an executable it is assumed that this needs to be
static.
2015-05-21 21:13:49 +02:00
Matt Clarkson
2cf24509bf Cast to char once masked
Masking the integer to 8bits still needs the cast to char as a char
could be unsigned resulting in a sign conversion
2015-05-21 21:13:25 +02:00
Matt Clarkson
1a3dba57f1 md5_append nbytes should be size_t
There will never be a time when the length of a string can be negative.
This makes the function arguments semantically correct but also solves
some of the casting and bit shifting errors inside the function.
2015-05-21 21:11:50 +02:00
Matt Clarkson
e213e1ba36 Do bit arithmetic with the correct type.
When shifting and ORing the bytes we should do it in the correct type
that we are going to assign to. In this case the types are signed and
unsigned so there is an implicit cast occuring.
2015-05-21 21:11:13 +02:00
Matt Clarkson
44be539a4a Add extra warnings
* -Wshadow
  * -Wmissing-prototypes
  * -Wsign-conversion
2015-05-21 21:10:03 +02:00
Matt Clarkson
c3b01db337 match_prefix takes it's length as size_t
The pattern length can never be negative, semantically it makes much more
sense to accept size_t as the pattern_length. This simplifies a lot of
the code elsewhere as the match_prefix is commonly called with
pattern_length set to the strlen which returns size_t
2015-05-21 21:09:37 +02:00
Matt Clarkson
82207dec8d Explicitly cast len to size_t
The mg_vsnprintf takes a size_t count but len is an integer. The value of
len should be greater than 0 from the previous statements so should be
safe to cast to size_t.
2015-05-21 21:08:57 +02:00
Matt Clarkson
4477a7c850 to_read should be size_t
The result of sizeof is size_t so we should use the correct type.
We can safely cast the arithmetic to size_t as the while loop checks
that the subtraction will not result in a negative number.
2015-05-21 21:08:25 +02:00