eidheim / Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
MIT License
2.61k stars 751 forks source link

fix a warning #137

Closed Arash-codedev closed 7 years ago

Arash-codedev commented 7 years ago

This commit is to fix the following warning:

 warning: value computed is not used [-Wunused-value]
         BIO_flush(b64);
                       ^
eidheim commented 7 years ago

Thank you, but I added error checks instead in https://github.com/eidheim/Simple-Web-Server/commit/f746027d379c2a2ea568f56dd80486e02b6a1874. By the way, what compiler did you use to receive this warning? I tried that flag in both newer clang++ and g++ but could not get that warning.

Arash-codedev commented 7 years ago

I use g++ but It is a surprise why I can no longer find such a warning too.

However, if you turn on -Wconversion switch, you will find 3 warnings. Would you like to send a fix for them?

In file included from /.../Simple-Web-Server/https_examples.cpp:2:0:
/.../Simple-Web-Server/server_https.hpp: In member function ‘virtual void SimpleWeb::Server<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp> > >::start()’:
/.../Simple-Web-Server/server_https.hpp:51:114: warning: conversion to ‘unsigned int’ from ‘long unsigned int’ may alter its value [-Wconversion]
                                        std::min<size_t>(session_id_context.size(), SSL_MAX_SSL_SESSION_ID_LENGTH));
                                                                                                                  ^
In file included from /.../Simple-Web-Server/https_examples.cpp:10:0:
/.../Simple-Web-Server/crypto.hpp: In static member function ‘static std::__cxx11::string SimpleWeb::Crypto::pbkdf2(const string&, const string&, int, int)’:
/.../Simple-Web-Server/crypto.hpp:215:82: warning: conversion to ‘int’ from ‘std::__cxx11::basic_string<char>::size_type {aka long unsigned int}’ may alter its value [-Wconversion]
                              key_size, reinterpret_cast<unsigned char *>(&key[0]));
                                                                                  ^
/.../Simple-Web-Server/crypto.hpp:215:82: warning: conversion to ‘int’ from ‘std::__cxx11::basic_string<char>::size_type {aka long unsigned int}’ may alter its value [-Wconversion]
eidheim commented 7 years ago

These warnings are about implicit conversions based on parameter types, and I do not see a real value in adding static_casts in these cases.

Thank you, -Wconversion helped, but I guess there is a reason why this flag is not part of -Wall and -Wextra. If you would like to silence these warnings from Simple-Web-Server, you can add the includes as system includes when compiling or in your build management system (cmake for instance).