Skip to content

Commit

Permalink
Merge pull request #12111 from hrydgard/static-analysis-fixes
Browse files Browse the repository at this point in the history
Static analysis fixes
  • Loading branch information
unknownbrackets authored Jun 18, 2019
2 parents 3cb1c33 + eb3faf5 commit 40d2d06
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 36 deletions.
7 changes: 5 additions & 2 deletions Core/MIPS/MIPSIntVFPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ namespace MIPSInt

int off = GetMatrixSide(sz) - 1;
u32 sprefixRemove = VFPU_ANY_SWIZZLE();
u32 sprefixAdd;
u32 sprefixAdd = 0;
switch ((op >> 16) & 0xF) {
case 3:
{
Expand All @@ -363,6 +363,9 @@ namespace MIPSInt
case 7:
sprefixAdd = VFPU_MAKE_CONSTANTS(VFPUConst::ONE, VFPUConst::ONE, VFPUConst::ONE, VFPUConst::ONE);
break;
default:
_dbg_assert_msg_(CPU, 0, "Unknown matrix init op");
break;
}
ApplyPrefixST(&prefixed[off * 4], VFPURewritePrefix(VFPU_CTRL_SPREFIX, sprefixRemove, sprefixAdd), V_Quad);
WriteMatrix(prefixed, sz, vd);
Expand Down Expand Up @@ -1562,7 +1565,7 @@ namespace MIPSInt
int vd = _VD;
int vs = _VS;
int vt = _VT;
int ins = (op >> 23) & 7;
int ins = (op >> 23) & 3;

VectorSize sz = (VectorSize)(ins + 1);
MatrixSize msz = (MatrixSize)(ins + 1);
Expand Down
11 changes: 5 additions & 6 deletions Core/Screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,26 +237,24 @@ static bool ConvertPixelTo8888RGBA(GPUDebugBufferFormat fmt, u8 &r, u8 &g, u8 &b
}

const u8 *ConvertBufferToScreenshot(const GPUDebugBuffer &buf, bool alpha, u8 *&temp, u32 &w, u32 &h) {
int pixelSize = alpha ? 4 : 3;
size_t pixelSize = alpha ? 4 : 3;
GPUDebugBufferFormat nativeFmt = alpha ? GPU_DBG_FORMAT_8888 : GPU_DBG_FORMAT_888_RGB;

w = std::min(w, buf.GetStride());
h = std::min(h, buf.GetHeight());

// The temp buffer will be freed by the caller if set, and can be the return value.
if (buf.GetFlipped() || buf.GetFormat() != nativeFmt) {
temp = new u8[pixelSize * w * h];
} else {
temp = nullptr;
}
temp = nullptr;

const u8 *buffer = buf.GetData();
if (buf.GetFlipped() && buf.GetFormat() == nativeFmt) {
temp = new u8[pixelSize * w * h];
// Silly OpenGL reads upside down, we flip to another buffer for simplicity.
for (u32 y = 0; y < h; y++) {
memcpy(temp + y * w * pixelSize, buffer + (buf.GetHeight() - y - 1) * buf.GetStride() * pixelSize, w * pixelSize);
}
} else if (buf.GetFormat() < GPU_DBG_FORMAT_FLOAT && buf.GetFormat() != nativeFmt) {
temp = new u8[pixelSize * w * h];
// Let's boil it down to how we need to interpret the bits.
int baseFmt = buf.GetFormat() & ~(GPU_DBG_FORMAT_REVERSE_FLAG | GPU_DBG_FORMAT_BRSWAP_FLAG);
bool rev = (buf.GetFormat() & GPU_DBG_FORMAT_REVERSE_FLAG) != 0;
Expand Down Expand Up @@ -284,6 +282,7 @@ const u8 *ConvertBufferToScreenshot(const GPUDebugBuffer &buf, bool alpha, u8 *&
}
}
} else if (buf.GetFormat() != nativeFmt) {
temp = new u8[pixelSize * w * h];
bool flip = buf.GetFlipped();

// This is pretty inefficient.
Expand Down
22 changes: 11 additions & 11 deletions GPU/Common/GPUDebugInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ inline GPUDebugBufferFormat &operator |=(GPUDebugBufferFormat &lhs, const GPUDeb
}

struct GPUDebugBuffer {
GPUDebugBuffer() : alloc_(false), data_(NULL) {
GPUDebugBuffer() {
}

GPUDebugBuffer(void *data, u32 stride, u32 height, GEBufferFormat fmt, bool reversed = false)
Expand All @@ -100,22 +100,22 @@ struct GPUDebugBuffer {
: alloc_(false), data_((u8 *)data), stride_(stride), height_(height), fmt_(fmt), flipped_(false) {
}

GPUDebugBuffer(GPUDebugBuffer &&other) {
GPUDebugBuffer(GPUDebugBuffer &&other) noexcept {
alloc_ = other.alloc_;
data_ = other.data_;
height_ = other.height_;
stride_ = other.stride_;
flipped_ = other.flipped_;
fmt_ = other.fmt_;
other.alloc_ = false;
other.data_ = NULL;
other.data_ = nullptr;
}

~GPUDebugBuffer() {
Free();
}

GPUDebugBuffer &operator = (GPUDebugBuffer &&other) {
GPUDebugBuffer &operator = (GPUDebugBuffer &&other) noexcept {
if (this != &other) {
Free();
alloc_ = other.alloc_;
Expand All @@ -125,7 +125,7 @@ struct GPUDebugBuffer {
flipped_ = other.flipped_;
fmt_ = other.fmt_;
other.alloc_ = false;
other.data_ = NULL;
other.data_ = nullptr;
}

return *this;
Expand Down Expand Up @@ -164,12 +164,12 @@ struct GPUDebugBuffer {
private:
u32 PixelSize(GPUDebugBufferFormat fmt) const;

bool alloc_;
u8 *data_;
u32 stride_;
u32 height_;
GPUDebugBufferFormat fmt_;
bool flipped_;
bool alloc_ = false;
u8 *data_ = nullptr;
u32 stride_ = 0;
u32 height_ = 0;
GPUDebugBufferFormat fmt_ = GPU_DBG_FORMAT_INVALID;
bool flipped_ = false;
};

struct GPUDebugVertex {
Expand Down
4 changes: 2 additions & 2 deletions ext/native/thin3d/VulkanQueueRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ class VulkanQueueRunner {

VulkanContext *vulkan_;

VkFramebuffer backbuffer_;
VkImage backbufferImage_;
VkFramebuffer backbuffer_ = VK_NULL_HANDLE;
VkImage backbufferImage_ = VK_NULL_HANDLE;

VkRenderPass backbufferRenderPass_ = VK_NULL_HANDLE;
VkRenderPass framebufferRenderPass_ = VK_NULL_HANDLE;
Expand Down
2 changes: 1 addition & 1 deletion ext/native/thin3d/VulkanRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void VulkanRenderManager::CreateBackbuffers() {
VkCommandBuffer cmdInit = GetInitCmd();

for (uint32_t i = 0; i < swapchainImageCount_; i++) {
SwapchainImageData sc_buffer;
SwapchainImageData sc_buffer{};
sc_buffer.image = swapchainImages[i];

VkImageViewCreateInfo color_image_view = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO };
Expand Down
6 changes: 3 additions & 3 deletions ext/native/thin3d/VulkanRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ class VulkanRenderManager {
FrameData frameData_[VulkanContext::MAX_INFLIGHT_FRAMES];

// Submission time state
int curWidth_;
int curHeight_;
int curWidth_ = -1;
int curHeight_ = -1;
bool insideFrame_ = false;
VKRStep *curRenderStep_ = nullptr;
std::vector<VKRStep *> steps_;
Expand All @@ -310,7 +310,7 @@ class VulkanRenderManager {
};
std::vector<VkFramebuffer> framebuffers_;
std::vector<SwapchainImageData> swapchainImages_;
uint32_t swapchainImageCount_;
uint32_t swapchainImageCount_ = 0;
struct DepthBufferInfo {
VkFormat format = VK_FORMAT_UNDEFINED;
VkImage image = VK_NULL_HANDLE;
Expand Down
14 changes: 7 additions & 7 deletions ext/native/ui/ui_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class PopupScreen : public UIDialogScreen {

class ListPopupScreen : public PopupScreen {
public:
ListPopupScreen(std::string title) : PopupScreen(title), showButtons_(false) {}
ListPopupScreen(std::string title) : PopupScreen(title) {}
ListPopupScreen(std::string title, const std::vector<std::string> &items, int selected, std::function<void(int)> callback, bool showButtons = false)
: PopupScreen(title, "OK", "Cancel"), adaptor_(items, selected), callback_(callback), showButtons_(showButtons) {
}
Expand All @@ -135,13 +135,13 @@ class ListPopupScreen : public PopupScreen {
virtual bool ShowButtons() const override { return showButtons_; }
virtual void CreatePopupContents(UI::ViewGroup *parent) override;
UI::StringVectorListAdaptor adaptor_;
UI::ListView *listView_;
UI::ListView *listView_ = nullptr;

private:
UI::EventReturn OnListChoice(UI::EventParams &e);

std::function<void(int)> callback_;
bool showButtons_;
bool showButtons_ = false;
std::set<int> hidden_;
};

Expand Down Expand Up @@ -169,7 +169,7 @@ namespace UI {
class SliderPopupScreen : public PopupScreen {
public:
SliderPopupScreen(int *value, int minValue, int maxValue, const std::string &title, int step = 1, const std::string &units = "")
: PopupScreen(title, "OK", "Cancel"), units_(units), value_(value), minValue_(minValue), maxValue_(maxValue), step_(step) {}
: PopupScreen(title, "OK", "Cancel"), units_(units), value_(value), minValue_(minValue), maxValue_(maxValue), step_(step) {}
virtual void CreatePopupContents(ViewGroup *parent) override;

void SetNegativeDisable(const std::string &str) {
Expand All @@ -185,12 +185,12 @@ class SliderPopupScreen : public PopupScreen {
EventReturn OnTextChange(EventParams &params);
EventReturn OnSliderChange(EventParams &params);
virtual void OnCompleted(DialogResult result) override;
Slider *slider_;
UI::TextEdit *edit_;
Slider *slider_ = nullptr;
UI::TextEdit *edit_ = nullptr;
std::string units_;
std::string negativeLabel_;
int *value_;
int sliderValue_;
int sliderValue_ = 0;
int minValue_;
int maxValue_;
int step_;
Expand Down
6 changes: 3 additions & 3 deletions ext/native/ui/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ class Slider : public Clickable {
float paddingLeft_;
float paddingRight_;
int step_;
int repeat_;
int repeatCode_;
int repeat_ = 0;
int repeatCode_ = 0;
};

class SliderFloat : public Clickable {
Expand All @@ -580,7 +580,7 @@ class SliderFloat : public Clickable {
float paddingLeft_;
float paddingRight_;
int repeat_;
int repeatCode_;
int repeatCode_ = 0;
};

// Basic button that modifies a bitfield based on the pressed status. Supports multitouch.
Expand Down
2 changes: 1 addition & 1 deletion ext/native/util/text/wrap_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WordWrapper {
// Position the current word starts at.
float x_ = 0.0f;
// Most recent width of word since last index.
float wordWidth_;
float wordWidth_ = 0.0f;
// Force the next word to cut partially and wrap.
bool forceEarlyWrap_ = false;
};

0 comments on commit 40d2d06

Please sign in to comment.