How Not To Code
1,511 FOLLOWERS
Tips and tricks on how to avoid errors in C/C /C# on real examples and recommendations how to fix them.
How Not To Code
9M ago
In 2021, the fintech industry experienced a significant surge, due…
Read more
The post How to Build a Fintech Mobile App: Trends, Features and Costs – fintech mobile app development appeared first on Coding School ..read more
How Not To Code
1y ago
These days, phone call and text spam has become an…
Read more
The post Answers to the Most Common Questions We Get Regarding Spam appeared first on Coding School ..read more
How Not To Code
1y ago
C# programming language can be called one of the most…
Read more
The post C# appeared first on Coding School ..read more
How Not To Code
1y ago
We will teach you all the basics of algorithmic thinking,…
Read more
The post C/ C++ appeared first on Coding School ..read more
How Not To Code
1y ago
BUG OF THE MONTH | Free of Pointer not at Start of Buffer
V726 An attempt to free memory containing the ‘wbuf’ array by using the ‘free’ function. This is incorrect as ‘wbuf’ was created on stack. log.cpp 216
template<typename T>
static ALWAYS_INLINE void FormatLogMessageAndPrintW(....)
{
....
wchar_t wbuf[512];
wchar_t* wmessage_buf = wbuf;
....
if (wmessage_buf != wbuf)
{
std::free(wbuf);
}
if (message_buf != buf)
{
std::free(message_buf);
}
....
}
Here the analyzer detected code with an error. In this code fragment, we see an attempt to delete an ..read more
How Not To Code
1y ago
BUG OF THE MONTH | Erroneous postfix
private async Task<HttpResponseMessage> CallFreshdeskApiAsync(
HttpRequestMessage request,
int retriedCount = 0)
{
try
{
request.Headers.Add("Authorization", _freshdeskAuthkey);
var response = await _httpClient.SendAsync(request);
if ( response.StatusCode != System.Net.HttpStatusCode.TooManyRequests
|| retriedCount > 3)
{
return response;
}
}
catch
{
if (retriedCount > 3)
{
throw;
}
}
await Task.Delay(30000 * (retriedCount + 1));
return await CallFreshdeskApiAsync(reques ..read more
How Not To Code
1y ago
BUG OF THE MONTH | An always-false expression
V547 Expression ‘h == 0’ is always false. jpegcodec.cpp 252
BLResult blJpegDecoderImplProcessMarker(....) noexcept {
uint32_t h = blMemReadU16uBE(p + 1);
// ....if (h == 0)
return blTraceError(BL_ERROR_JPEG_UNSUPPORTED_FEATURE);
// ....
impl->delayedHeight = (h == 0); // <=// ....
}
In this code fragment, the result of the blMemReadU16uBE function call is assigned to the h variable. Then if the h == 0 check is true, we exit from the function’s body. During initialization impl->delayedH ..read more
How Not To Code
1y ago
BUG OF THE MONTH | Assignment to Variable without Use
private void Draw(Rect windowRect)
{
var rect = new Rect(....);
....
if (m_NumFilteredVariants > 0)
{
....
if (m_NumFilteredVariants > maxFilteredLength)
{
GUI.Label(....);
rect.y += rect.height;
}
}
else
{
GUI.Label(rect, "No variants with these keywords");
rect.y += rect.height; // <=
}
rect.y = windowRect.height - kMargin - kSpaceHeight –
EditorGUI.kSingleLineHeight; // <=
....
}
V3008 The ‘rect ..read more
How Not To Code
1y ago
BUG OF THE MONTH | Unnecessary actions
V3107 Identical expression ‘power’ to the left and to the right of compound assignment. RelayComponent.cs 150
public override void ReceivePowerProbeSignal(Connection connection,
Item source, float power)
{
....
if (power < 0.0f)
{
....
}
else
{
if (connection.IsOutput || powerOut == null) { return; }
if (currPowerConsumption - power < -MaxPower)
{
power += MaxPower + (currPowerConsumption - power);
}
}
}
The programmer is trying to add MaxPower,  ..read more
How Not To Code
1y ago
Videos that analyze errors in software projects are an excellent opportunity to practice coding and learn from other people’s mistakes. This time we’ll analyze the .NET 6 source code.
Have fun watching this video and coding ..read more