Skip to content

Commit

Permalink
Fix codacy advisories, deprecate HttpRequest copy operator
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Feb 18, 2019
1 parent ccf1165 commit b18982a
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 31 deletions.
8 changes: 4 additions & 4 deletions Sming/SmingCore/Network/FTPServerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class FTPDataStream : public TcpConnection
{
public:
FTPDataStream(FTPServerConnection* connection) : TcpConnection(true), parent(connection)
explicit FTPDataStream(FTPServerConnection* connection) : TcpConnection(true), parent(connection)
{
}

Expand Down Expand Up @@ -70,7 +70,7 @@ class FTPDataStream : public TcpConnection
class FTPDataFileList : public FTPDataStream
{
public:
FTPDataFileList(FTPServerConnection* connection) : FTPDataStream(connection)
explicit FTPDataFileList(FTPServerConnection* connection) : FTPDataStream(connection)
{
}

Expand Down Expand Up @@ -164,10 +164,10 @@ err_t FTPServerConnection::onReceive(pbuf* buf)
{
if(buf == nullptr)
return ERR_OK;
int p = 0, prev = 0;
int prev = 0;

while(true) {
p = NetUtils::pbufFindStr(buf, "\r\n", prev);
int p = NetUtils::pbufFindStr(buf, "\r\n", prev);
if(p < 0 || p - prev > MAX_FTP_CMD) {
break;
}
Expand Down
11 changes: 10 additions & 1 deletion Sming/SmingCore/Network/Http/HttpHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,18 @@ enum HttpHeaderFieldName {
*
* @todo add name and/or value escaping
*/
class HttpHeaders : private HashMap<HttpHeaderFieldName, String>
class HttpHeaders : protected HashMap<HttpHeaderFieldName, String>
{
public:
HttpHeaders()
{
}

HttpHeaders(const HttpHeaders& headers)
{
*this = headers;
}

String toString(HttpHeaderFieldName name) const;

/** @brief Produce a string for output in the HTTP header, with line ending
Expand Down
5 changes: 1 addition & 4 deletions Sming/SmingCore/Network/Http/HttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
#include "Data/Stream/ChunkedStream.h"
#include "Data/Stream/UrlencodedOutputStream.h"

HttpRequest::HttpRequest(const HttpRequest& value) : uri(value.uri)
HttpRequest::HttpRequest(const HttpRequest& value) : uri(value.uri), method(value.method), headers(value.headers)
{
*this = value;
method = value.method;
headers = value.headers;
headersCompletedDelegate = value.headersCompletedDelegate;
requestBodyDelegate = value.requestBodyDelegate;
requestCompletedDelegate = value.requestCompletedDelegate;
Expand Down
3 changes: 2 additions & 1 deletion Sming/SmingCore/Network/Http/HttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class HttpRequest
return new HttpRequest(*this);
}

HttpRequest& operator=(const HttpRequest& rhs);
/** @deprecated Please use `clone()` instead */
HttpRequest& operator=(const HttpRequest& rhs) SMING_DEPRECATED;

~HttpRequest()
{
Expand Down
8 changes: 2 additions & 6 deletions Sming/SmingCore/Network/Http/HttpRequestAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ class AuthAdapter
class HttpBasicAuth : public AuthAdapter
{
public:
HttpBasicAuth(const String& username, const String& password)
HttpBasicAuth(const String& username, const String& password) : username(username), password(password)
{
this->username = username;
this->password = password;
}

void setRequest(HttpRequest* request);
Expand All @@ -50,10 +48,8 @@ class HttpBasicAuth : public AuthAdapter
class HttpDigestAuth : public AuthAdapter
{
public:
HttpDigestAuth(const String& username, const String& password)
HttpDigestAuth(const String& username, const String& password) : username(username), password(password)
{
this->username = username;
this->password = password;
}

void setRequest(HttpRequest* request)
Expand Down
7 changes: 1 addition & 6 deletions Sming/SmingCore/Platform/Station.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,19 +451,14 @@ void StationClass::wpsConfigStop()

BssInfo::BssInfo(bss_info* info)
{
ssid = String((char*)info->ssid);
ssid = reinterpret_cast<const char*>(info->ssid);
memcpy(bssid, info->bssid, sizeof(bssid));
authorization = info->authmode;
channel = info->channel;
rssi = info->rssi;
hidden = info->is_hidden;
}

bool BssInfo::isOpen()
{
return authorization == AUTH_OPEN;
}

const char* BssInfo::getAuthorizationMethodName()
{
switch(authorization) {
Expand Down
5 changes: 4 additions & 1 deletion Sming/SmingCore/Platform/Station.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ class BssInfo
/** @brief Get BSS open status
* @retval bool True if BSS open
*/
bool isOpen();
bool isOpen()
{
return authorization == AUTH_OPEN;
}

/** @brief Get BSS authorisation method name
* @retval char* Pointer to c string BSS authoristation method name
Expand Down
9 changes: 3 additions & 6 deletions Sming/SmingCore/SPISoft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ void SPISoft::begin()

void SPISoft::transfer(uint8_t* buffer, uint32_t size)
{
uint8_t d;
uint8_t r;
do {
d = *buffer;
r = 0;
uint8_t d = *buffer;

GP_OUT(mMOSI, d & 0x80); /* bit7 */
r = GP_IN(mMISO); //bit 7
GP_OUT(mMOSI, d & 0x80); /* bit7 */
uint8_t r = GP_IN(mMISO); //bit 7
SCK_PULSE
GP_OUT(mMOSI, d & 0x40); /* bit6 */
r = r << 1 | GP_IN(mMISO); //bit 6
Expand Down
3 changes: 1 addition & 2 deletions Sming/Wiring/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ int Stream::timedPeek()
// discards non-numeric characters
int Stream::peekNextDigit()
{
int c;
while (1) {
c = timedPeek();
int c = timedPeek();
if (c < 0) return c; // timeout
if (c == '-') return c;
if (c >= '0' && c <= '9') return c;
Expand Down

0 comments on commit b18982a

Please sign in to comment.