Skip to content

Commit

Permalink
Eliminate variable assigned but never read [cppcheck]
Browse files Browse the repository at this point in the history
  • Loading branch information
LegalizeAdulthood committed Dec 31, 2024
1 parent f38d83e commit 401e2bd
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 24 deletions.
1 change: 0 additions & 1 deletion hc/AsciiDocCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ void AsciiDocProcessor::print_inside_key(char c)
}
else if (m_key_name.back() == ']')
{
const char last = m_key_name.back();
m_key_name.pop_back();
m_key_name += R"(\])";
}
Expand Down
1 change: 0 additions & 1 deletion libid/diffusion_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ inline void count_to_int(unsigned long C, int &x, int &y, int dif_offset)
x += s_dif_la[tC & 0xFF];
y <<= 4;
y += s_dif_lb[tC & 0xFF];
tC >>= 8;
x >>= dif_offset;
y >>= dif_offset;
}
Expand Down
16 changes: 4 additions & 12 deletions libid/get_3d_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,7 @@ static bool get_light_params()
{
ChoiceBuilder<13> builder;

int k;

// defaults go here

k = -1;

if (illumine() || g_raytrace_format != RayTraceFormat::NONE)
{
builder.int_number("X value light vector", g_light_x)
Expand Down Expand Up @@ -407,14 +402,12 @@ static bool get_light_params()

{
ValueSaver saved_help_mode{g_help_mode, HelpLabels::HELP_3D_LIGHT};
k = builder.prompt("Light Source Parameters");
}
if (k < 0)
{
return true;
if (builder.prompt("Light Source Parameters") < 0)
{
return true;
}
}

k = 0;
if (illumine())
{
g_light_x = builder.read_int_number();
Expand Down Expand Up @@ -448,7 +441,6 @@ static bool get_light_params()
}
g_light_name = builder.read_string();
/* In case light_name conflicts with an existing name it is checked again in line3d */
k++;
g_background_color[0] = (char)(builder.read_int_number() % 255);
g_background_color[1] = (char)(builder.read_int_number() % 255);
g_background_color[2] = (char)(builder.read_int_number() % 255);
Expand Down
6 changes: 2 additions & 4 deletions unix/x11_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,6 @@ void X11TextWindow::repaint(int xmin, int xmax, int ymin, int ymax)
*/
int istart = 0;
int jstart = 0;
unsigned char foreground = 0;
unsigned char background = 0;
for (int j = ymin; j <= ymax; j++)
{
int length = 0;
Expand All @@ -910,8 +908,8 @@ void X11TextWindow::repaint(int xmin, int xmax, int ymin, int ymax)
{
k = attributes_[j][i];
}
foreground = static_cast<unsigned char>(k & 15);
background = static_cast<unsigned char>(k >> 4);
unsigned char foreground = static_cast<unsigned char>(k & 15);
unsigned char background = static_cast<unsigned char>(k >> 4);
if (i > xmax || foreground != (int)oldfg || background != (int)oldbk)
{
if (length > 0)
Expand Down
4 changes: 2 additions & 2 deletions win32/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Frame::on_paint(HWND window)
}

PAINTSTRUCT ps;
HDC hDC = BeginPaint(window, &ps);
BeginPaint(window, &ps);
EndPaint(window, &ps);
}

Expand Down Expand Up @@ -1372,6 +1372,6 @@ void Frame::set_keyboard_timeout(int ms)
if (!result)
{
DWORD error = GetLastError();
_ASSERTE(result);
throw std::runtime_error("SetTimer failed: " + std::to_string(error));
}
}
6 changes: 4 additions & 2 deletions win32/Plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <windowsx.h>

#include <cstring>
#include <stdexcept>
#include <string>

#define PLOT_TIMER_ID 1

Expand Down Expand Up @@ -529,8 +531,8 @@ void Plot::schedule_alarm(int secs)
UINT_PTR result = SetTimer(m_window, PLOT_TIMER_ID, secs, redraw_window);
if (!result)
{
DWORD error = GetLastError();
_ASSERTE(result);
const DWORD error = GetLastError();
throw std::runtime_error("SetTimer failed: " + std::to_string(error));
}
}

Expand Down
6 changes: 4 additions & 2 deletions win32/WinText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <array> // std::size
#include <algorithm>
#include <cstring>
#include <stdexcept>
#include <string>

#define TIMER_ID 1

Expand Down Expand Up @@ -343,7 +345,7 @@ void WinText::on_kill_focus(HWND window, HWND old_focus)
void WinText::on_paint(HWND window)
{
PAINTSTRUCT ps;
HDC hDC = BeginPaint(window, &ps);
BeginPaint(window, &ps);

// the routine below handles *all* window updates
int xmin = ps.rcPaint.left/m_char_width;
Expand Down Expand Up @@ -741,7 +743,7 @@ void WinText::schedule_alarm(int secs)
if (!result)
{
DWORD error = GetLastError();
_ASSERTE(result);
throw std::runtime_error("SetTimer failed: " + std::to_string(error));
}
}

Expand Down

0 comments on commit 401e2bd

Please sign in to comment.