Skip to content

Commit 2e91125

Browse files
committed
Fix up coding style to suppress -Wall warnings
1 parent ae7867f commit 2e91125

File tree

9 files changed

+29
-24
lines changed

9 files changed

+29
-24
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ IF(MSVC)
3838
# "zero-length array in struct" from libusb.h
3939
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4244 /wd4200 /wd4305 /wd4146")
4040
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) # no warning for getenv()
41+
ELSE()
42+
# Heed warnings from non-MSVC compilers
43+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
4144
ENDIF()
4245

4346
IF(ENABLE_CXX11)

examples/viewer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ Viewer::Viewer() : shader_folder("src/shader/"),
66
win_width(600),
77
win_height(400)
88
{
9-
// init glfw - if already initialized nothing happens
10-
int init = glfwInit();
11-
129
}
1310

1411
static void glfwErrorCallback(int error, const char* description)
@@ -18,6 +15,9 @@ static void glfwErrorCallback(int error, const char* description)
1815

1916
void Viewer::initialize()
2017
{
18+
// init glfw - if already initialized nothing happens
19+
glfwInit();
20+
2121
GLFWerrorfun prev_func = glfwSetErrorCallback(glfwErrorCallback);
2222
if (prev_func)
2323
glfwSetErrorCallback(prev_func);

examples/viewer.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct Texture : public WithOpenGLBindings
6767
unsigned char *data;
6868
size_t size;
6969

70-
Texture() : texture(0), data(0), size(0), bytes_per_pixel(FormatT::BytesPerPixel), height(0), width(0)
70+
Texture() : bytes_per_pixel(FormatT::BytesPerPixel), height(0), width(0), texture(0), data(0), size(0)
7171
{
7272
}
7373

@@ -125,13 +125,13 @@ struct Texture : public WithOpenGLBindings
125125
{
126126
typedef unsigned char type;
127127

128-
int linestep = width * bytes_per_pixel / sizeof(type);
128+
size_t linestep = width * bytes_per_pixel / sizeof(type);
129129

130130
type *first_line = reinterpret_cast<type *>(data), *last_line = reinterpret_cast<type *>(data) + (height - 1) * linestep;
131131

132-
for (int y = 0; y < height / 2; ++y)
132+
for (size_t y = 0; y < height / 2; ++y)
133133
{
134-
for (int x = 0; x < linestep; ++x, ++first_line, ++last_line)
134+
for (size_t x = 0; x < linestep; ++x, ++first_line, ++last_line)
135135
{
136136
std::swap(*first_line, *last_line);
137137
}
@@ -271,8 +271,8 @@ class Viewer : WithOpenGLBindings {
271271
std::map<std::string,libfreenect2::Frame*> frames;
272272
Texture<F8C4> rgb;
273273
Texture<F32C1> ir;
274-
int win_height;
275274
int win_width;
275+
int win_height;
276276
public:
277277
Viewer();
278278
void initialize();

include/internal/libfreenect2/depth_packet_stream_parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class DepthPacketStreamParser : public DataCallback
7373
libfreenect2::DoubleBuffer buffer_;
7474
libfreenect2::Buffer work_buffer_;
7575

76+
uint32_t processed_packets_;
7677
uint32_t current_sequence_;
7778
uint32_t current_subsequence_;
78-
uint32_t processed_packets_;
7979
};
8080

8181
} /* namespace libfreenect2 */

include/internal/libfreenect2/protocol/response.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class FirmwareVersionResponse
101101
FWSubsystemVersion max;
102102
std::stringstream version_string;
103103
// the main blob's index
104-
int i = 3;
104+
size_t i = 3;
105105
if (i < versions_.size())
106106
{
107107
const FWSubsystemVersion &ver = versions_[i];

src/command_transaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CommandTransaction::Result::~Result()
4949

5050
void CommandTransaction::Result::allocate(size_t size)
5151
{
52-
if (capacity != size)
52+
if ((size_t)capacity != size)
5353
{
5454
deallocate();
5555
data = new unsigned char[size];
@@ -143,7 +143,7 @@ CommandTransaction::ResultCode CommandTransaction::send(const CommandBase& comma
143143
code = Error;
144144
}
145145

146-
if(transferred_bytes != command.size())
146+
if((size_t)transferred_bytes != command.size())
147147
{
148148
LOG_ERROR << "sent number of bytes differs from expected number! expected: " << command.size() << " got: " << transferred_bytes;
149149
code = Error;

src/cpu_depth_packet_processor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ class CpuDepthPacketProcessorImpl: public WithPerfLogging
617617
// if(DISABLE_DISAMBIGUATION)
618618
if(false)
619619
{
620+
#if 0
620621
//r0.yz = r3.zx + r4.zx // add
621622
//r0.yz = r5.xz + r0.zy // add
622623
float phase = m0[0] + m1[0] + m2[0]; // r0.y
@@ -628,6 +629,7 @@ class CpuDepthPacketProcessorImpl: public WithPerfLogging
628629
//r3.zw = r4.xy // mov
629630
float tmp3 = m0[2] + m1[2] + m2[2]; // r3.z
630631
float tmp4 = m0[1] + m1[1] + m2[1]; // r3.w
632+
#endif
631633
}
632634
else
633635
{

src/libfreenect2.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ class Freenect2Impl
305305
Freenect2Impl(void *usb_context) :
306306
managed_usb_context_(usb_context == 0),
307307
usb_context_(reinterpret_cast<libusb_context *>(usb_context)),
308-
initialized(false),
309-
has_device_enumeration_(false)
308+
has_device_enumeration_(false),
309+
initialized(false)
310310
{
311311
#ifdef __linux__
312312
if (libusb_get_version()->nano < 10952)
@@ -755,7 +755,7 @@ bool Freenect2DeviceImpl::start()
755755
for (uint32_t status = 0, last = 0; (status & 1) == 0; last = status)
756756
{
757757
command_tx_.execute(ReadStatus0x090000Command(nextCommandSeq()), result);
758-
if (result.length < sizeof(uint32_t))
758+
if ((size_t)result.length < sizeof(uint32_t))
759759
continue; //TODO should report error
760760
status = *reinterpret_cast<const uint32_t *>(result.data);
761761
if (status != last)
@@ -769,7 +769,7 @@ bool Freenect2DeviceImpl::start()
769769
usb_control_.setIrInterfaceState(UsbControl::Enabled);
770770

771771
command_tx_.execute(ReadStatus0x090000Command(nextCommandSeq()), result);
772-
if (result.length >= sizeof(uint32_t))
772+
if ((size_t)result.length >= sizeof(uint32_t))
773773
LOG_DEBUG << "status 0x090000: " << *reinterpret_cast<const uint32_t *>(result.data);
774774

775775
command_tx_.execute(SetStreamEnabledCommand(nextCommandSeq()), result);

src/opengl_depth_packet_processor.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ struct ShaderProgram : public WithOpenGLBindings
124124

125125
ShaderProgram() :
126126
program(0),
127-
is_mesa_checked(false),
128127
vertex_shader(0),
129-
fragment_shader(0)
128+
fragment_shader(0),
129+
is_mesa_checked(false)
130130
{
131131
}
132132

@@ -296,7 +296,7 @@ struct Texture : public WithOpenGLBindings
296296
unsigned char *data;
297297
size_t size;
298298

299-
Texture() : texture(0), data(0), size(0), bytes_per_pixel(FormatT::BytesPerPixel), height(0), width(0)
299+
Texture() : bytes_per_pixel(FormatT::BytesPerPixel), height(0), width(0), texture(0), data(0), size(0)
300300
{
301301
}
302302

@@ -314,7 +314,7 @@ struct Texture : public WithOpenGLBindings
314314

315315
GLint max_size;
316316
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE, &max_size);
317-
if (new_width > max_size || new_height > max_size)
317+
if (new_width > (size_t)max_size || new_height > (size_t)max_size)
318318
{
319319
LOG_ERROR << "GL_MAX_RECTANGLE_TEXTURE_SIZE is too small: " << max_size;
320320
exit(-1);
@@ -363,13 +363,13 @@ struct Texture : public WithOpenGLBindings
363363
{
364364
typedef unsigned char type;
365365

366-
int linestep = width * bytes_per_pixel / sizeof(type);
366+
size_t linestep = width * bytes_per_pixel / sizeof(type);
367367

368368
type *first_line = reinterpret_cast<type *>(data), *last_line = reinterpret_cast<type *>(data) + (height - 1) * linestep;
369369

370-
for(int y = 0; y < height / 2; ++y)
370+
for(size_t y = 0; y < height / 2; ++y)
371371
{
372-
for(int x = 0; x < linestep; ++x, ++first_line, ++last_line)
372+
for(size_t x = 0; x < linestep; ++x, ++first_line, ++last_line)
373373
{
374374
std::swap(*first_line, *last_line);
375375
}
@@ -431,8 +431,8 @@ class OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPer
431431

432432
OpenGLDepthPacketProcessorImpl(GLFWwindow *new_opengl_context_ptr, bool debug) :
433433
opengl_context_ptr(new_opengl_context_ptr),
434-
square_vao(0),
435434
square_vbo(0),
435+
square_vao(0),
436436
stage1_framebuffer(0),
437437
filter1_framebuffer(0),
438438
stage2_framebuffer(0),

0 commit comments

Comments
 (0)