Cleanup warnings optimized#28
Conversation
This causes source files which depend on headers to be rebuilt when the header changes. `-MMD` generates the dependencies in `*.d` files, excluding system headers. `-MP` adds fake rules for headers to the dependencies file so build doesn't break if a header is removed. Update `.gitignore` to ignore new `*.d` files.
Instead of using `gcc` to compile both C and C++, use `gcc` for C and `g++` for C++. This allows to split flags more cleanly. Re-organize flag variables a bit, adding `CPPFLAGS` for C preprocessor flags, `CFLAGS` for C compiler flags and `CXXFLAGS` for C++ compiler flags.
This makes it easier to see the build output/warnings. Full build output can be enabled with `make V=1`.
Include common.mk from the other Makefiles instead of exporting variables from the top-level Makefile so they get expanded correctly.
The checked value is a fixed-sized array, not a pointer so it can't be NULL.
Move it up in the tcp.c file so it's defined before use.
Silences GCC warning and aids readability.
This file isn't included anywhere.
Looks like similar/same bug in csocket_http_client.cpp and csocket_http_server.cpp.
Since data type is `uint16_t` it can't be less than 0 or more than (or equal to) `MAX_PORTS`.
Fixes compiler warnings since with `uint16_t` it always evaluates to true and `int` feels quite natural anyway.
The left shift of uint8_t `type` variable promotes it to and int type and then or-ing with promotes `descriptor_index` to an int so cast it back to uint16_t to remove the warning and make the conversion explicit.
Using `{}` is valid in C and C++ and causes all members to be zero
initialized without explicitly stating them. This entire loop
wouldn't be needed if `shortcuts` was made a static variable
since it would automatically be zero-initialized.
The left shift promotes `type` to int and then or-ing with `descriptor_index` promotes that to int, so we need to cast it back to intended uint16_t type.
Make both sides of comparison unsigned.
The `{}` is valid C/C++ and will zero-initialize without causing
this warning.
| va_list args; | ||
| va_start(args, fmt); | ||
| char* buf = kalloc(print_buf, 256, ALIGN_64B, true, false); | ||
| size_t len = string_format_va_buf(fmt, buf, args); |
There was a problem hiding this comment.
Pretty sure removing this would lead to the infamous alignment fault in printf from last week, and since I made changes there, it might lead to a lot of merge conflicts. Please check your branch against /console
There was a problem hiding this comment.
Pretty sure removing this would lead to the infamous alignment fault in printf from last week, and since I made changes there, it might lead to a lot of merge conflicts. Please check your branch against /console
Interesting, I will check/update it soon when I get some time. It seems weird that not using the result of a function could cause alignment issues, but stranger things have happened. If the result must be used, using the C attribute [[nodiscard]] or GCC attribute warn_unused_result may be advised. Should also be able to just cast the result to void (ex. (void)string_format_va_buf(...) to squelch the warning. Will investigate it more.
There was a problem hiding this comment.
I found it weird too, but it has to do with an alignment issue on va_list. Having another variable on the stack made va_list align to 16 bits, without the variable, it was aligned to 8 which is not allowed. It's all fixed in the console branch I merged yesterday, and this variable is actually being used, so this won't matter anyway
A few more legit compile warnings found by enabling compiler optimizations.
Depends on #27
As was mentioned on-stream, enabling optimizations breaks everything due to missing volatiles and such, but these look simple/legit.
Edit: don't merge this, I will fix it if and when #27 gets merged.