squelch some more compiler warnings

This commit is contained in:
David Rose 2011-06-18 00:16:48 +00:00
parent 5cdc46bf0b
commit 4785161374
26 changed files with 207 additions and 189 deletions

View File

@ -714,7 +714,7 @@ $[cdefine USE_DELETED_CHAIN]
$[cdefine WANT_NATIVE_NET]
/* Turn off warnings for using scanf and such */
#if $[or $[eq $[USE_COMPILER],MSVC9], $[USE_COMPILER],MSVC9x64]
#if $[or $[eq $[USE_COMPILER],MSVC9], $[eq $[USE_COMPILER],MSVC9x64]]
#print Will ignore CRT_SECURE warnings for MSVC9
$[cdefine _CRT_SECURE_NO_WARNINGS]
# pragma warning( disable : 4996 4275 4267 4099 4049 4013 4005 )

View File

@ -336,10 +336,13 @@ seekoff(streamoff off, ios_seekdir dir, ios_openmode which) {
}
#else
// Posix case.
new_pos = lseek(_fd, off, SEEK_END);
if (new_pos == -1) {
{
off_t li = lseek(_fd, off, SEEK_END);
if (li == (size_t)-1) {
return -1;
}
new_pos = (size_t)li;
}
#endif // _WIN32
break;

View File

@ -398,7 +398,7 @@ get_call_str(const string &container, const vector_string &pexprs) const {
if (_cpptype != NULL) {
// Fix nested classes by replacing :: with __
char* nested_name = strdup(_cpptype->get_local_name(&parser).c_str());
for (int i = 0; i < strlen(nested_name); ++i) {
for (size_t i = 0; i < strlen(nested_name); ++i) {
if (nested_name[i] == ':') {
nested_name[i] = '_';
}
@ -681,7 +681,7 @@ setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface_mak
}
} else if (fname == "size" || fname == "__len__") {
if (_parameters.size() == first_param &&
if ((int)_parameters.size() == first_param &&
TypeManager::is_integer(_return_type->get_new_type())) {
// It receives no parameters, and returns an integer.
_flags |= F_size;

View File

@ -118,8 +118,6 @@ InterfaceMaker::Object::
////////////////////////////////////////////////////////////////////
void InterfaceMaker::Object::
check_protocols() {
InterrogateDatabase *idb = InterrogateDatabase::get_ptr();
int flags = 0;
Functions::const_iterator fi;

View File

@ -46,38 +46,39 @@ OpenALAudioSound(OpenALAudioManager* manager,
int mode) :
_movie(movie),
_sd(NULL),
_loops_completed(0),
_playing_rate(0.0),
_playing_loops(0),
_playing_rate(0.0),
_loops_completed(0),
_source(0),
_manager(manager),
_basename(movie->get_filename().get_basename()),
_volume(1.0f),
_balance(0),
_loop_count(1),
_length(0.0),
_start_time(0.0),
_play_rate(1.0),
_positional(positional),
_min_dist(3.28f),
_max_dist(1000000000.0f),
_drop_off_factor(1.0f),
_length(0.0),
_loop_count(1),
_desired_mode(mode),
_start_time(0.0),
_current_time(0.0),
_basename(movie->get_filename().get_basename()),
_active(true),
_paused(false),
_desired_mode(mode)
_paused(false)
{
_location[0] = 0;
_location[1] = 0;
_location[2] = 0;
_velocity[0] = 0;
_velocity[1] = 0;
_velocity[2] = 0;
_min_dist = 3.28f; _max_dist = 1000000000.0f;
_drop_off_factor = 1.0f;
_positional = positional;
_location[0] = 0.0f;
_location[1] = 0.0f;
_location[2] = 0.0f;
_velocity[0] = 0.0f;
_velocity[1] = 0.0f;
_velocity[2] = 0.0f;
require_sound_data();
if (_manager == 0) return;
if (_manager == NULL) {
return;
}
_length = _sd->_length;
if (positional) {
if (_sd->_channels != 1) {
@ -506,7 +507,7 @@ push_fresh_buffers() {
int rate = cursor->audio_rate();
int fill = 0;
for (int i=0; i<_stream_queued.size(); i++) {
for (size_t i = 0; i < _stream_queued.size(); i++) {
fill += _stream_queued[i]._samples;
}

View File

@ -22,9 +22,9 @@
INLINE MovingPartBase::
MovingPartBase(const MovingPartBase &copy) :
PartGroup(copy),
_forced_channel(copy._forced_channel),
_num_effective_channels(0),
_effective_control(NULL)
_effective_control(NULL),
_forced_channel(copy._forced_channel)
{
// We don't copy the bound channels. We do copy the forced_channel,
// though this is just a pointerwise copy.

View File

@ -84,11 +84,11 @@ INLINE CollisionBox::
CollisionBox(const CollisionBox &copy) :
CollisionSolid(copy),
_center(copy._center),
_min(copy._min),
_max(copy._max),
_x(copy._x ),
_y(copy._y ),
_z(copy._z ),
_min( copy._min),
_max( copy._max),
_radius(copy._radius )
{
for(int v = 0; v < 8; v++)
@ -350,12 +350,12 @@ operator = (const CollisionBox::PointDef &copy) {
_p = copy._p;
_v = copy._v;
}
////////////////////////////////////////////////////////////////////
// Function: CollisionBox::get_plane_points
// Access: Public
// Description: returns the points that form the nth plane
////////////////////////////////////////////////////////////////////
INLINE CollisionBox::Points CollisionBox::
get_plane_points(int n) {
return _points[n];

View File

@ -12,8 +12,6 @@
//
////////////////////////////////////////////////////////////////////
#include "collisionDSSolid.h"
#include "collisionBox.h"
#include "collisionLine.h"
#include "collisionRay.h"
@ -277,7 +275,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
float from_radius = csqrt(from_radius_2);
int ip;
float max_dist,dist;
float max_dist = 0.0;
float dist = 0.0;
bool intersect;
Planef plane;
LVector3f normal;
@ -465,7 +464,8 @@ test_intersection_from_ray(const CollisionEntry &entry) const {
LVector3f from_direction = ray->get_direction() * wrt_mat;
int i, j;
float t, near_t;
float t;
float near_t = 0.0;
bool intersect;
Planef plane;
Planef near_plane;
@ -548,7 +548,8 @@ test_intersection_from_segment(const CollisionEntry &entry) const {
LVector3f from_direction = from_extent - from_origin;
int i, j;
float t, near_t;
float t;
float near_t = 0.0;
bool intersect;
Planef plane;
Planef near_plane;

View File

@ -49,7 +49,7 @@ begin_group() {
}
_last_colliding.clear();
if (_closest_collider) {
bool inserted = _last_colliding.insert(_closest_collider).second;
_last_colliding.insert(_closest_collider);
}
_current_colliding.clear();
_collider_distance = 0;
@ -86,7 +86,7 @@ add_entry(CollisionEntry *entry) {
bool CollisionHandlerHighestEvent::
end_group() {
if (_closest_collider) {
bool inserted = _current_colliding.insert(_closest_collider).second;
_current_colliding.insert(_closest_collider);
}
return CollisionHandlerEvent::end_group();
}

View File

@ -478,8 +478,6 @@ test_intersection_from_box(const CollisionEntry &entry) const {
LPoint3f orig_center = get_center();
LPoint3f to_center = orig_center;
bool moved_from_center = false;
float t = 1.0f;
LPoint3f contact_point(from_center);
float actual_t = 1.0f;
@ -487,7 +485,8 @@ test_intersection_from_box(const CollisionEntry &entry) const {
float to_radius_2 = to_radius * to_radius;
int ip;
float max_dist,dist;
float max_dist = 0.0f;
float dist = 0.0f; // initial assignment to squelch silly compiler warning
bool intersect;
Planef plane;
LVector3f normal;

View File

@ -64,11 +64,11 @@ SubprocessWindowBuffer(int x_size, int y_size) {
////////////////////////////////////////////////////////////////////
SubprocessWindowBuffer::
SubprocessWindowBuffer(const SubprocessWindowBuffer &copy) :
_mmap_size(copy._mmap_size),
_x_size(copy._x_size),
_y_size(copy._y_size),
_row_size(copy._row_size),
_framebuffer_size(copy._framebuffer_size),
_mmap_size(copy._mmap_size)
_framebuffer_size(copy._framebuffer_size)
{
memcpy(_this_magic, _magic_number, magic_number_length);
_event_in = 0;

View File

@ -1004,7 +1004,8 @@ string_cs_type(const string &strval) {
return CST_inv_sphere;
} else if (cmp_nocase_uh(strval, "tube") == 0) {
return CST_tube;
} else if (cmp_nocase_uh(strval, "floor-mesh") == 0) {
} else if (cmp_nocase_uh(strval, "floor-mesh") == 0 ||
cmp_nocase_uh(strval, "floormesh") == 0) {
return CST_floor_mesh;
} else {
return CST_none;
@ -1491,6 +1492,8 @@ ostream &operator << (ostream &out, EggGroup::CollisionSolidType t) {
return out << "InvSphere";
case EggGroup::CST_tube:
return out << "Tube";
case EggGroup::CST_floor_mesh:
return out << "FloorMesh";
}
nassertr(false, out);

View File

@ -550,7 +550,7 @@ has_alpha_channel(int num_components) const {
// Function: EggTexture::affects_polygon_alpha
// Access: Published
// Description: Returns true if this texture's environment type or
// combine mode allows the texture to have an affect on
// combine mode allows the texture to have an effect on
// the polygon's alpha values, false otherwise.
////////////////////////////////////////////////////////////////////
bool EggTexture::
@ -564,13 +564,13 @@ affects_polygon_alpha() const {
case ET_blend:
case ET_add:
case ET_blend_color_scale:
return false;
case ET_modulate_glow:
case ET_modulate_gloss:
case ET_normal:
case ET_normal_height:
case ET_glow:
case ET_gloss:
case ET_height:
return false;
case ET_selector:

View File

@ -1013,7 +1013,7 @@ finish_sort_group() {
filter_timeslice_priority();
}
nassertr(_num_tasks == _active.size() + _this_active.size() + _next_active.size() + _sleeping.size(), true);
nassertr((size_t)_num_tasks == _active.size() + _this_active.size() + _next_active.size() + _sleeping.size(), true);
make_heap(_active.begin(), _active.end(), AsyncTaskSortPriority());
_current_sort = -INT_MAX;
@ -1419,12 +1419,11 @@ do_write(ostream &out, int indent_level) const {
if (!tasks.empty()) {
sort(tasks.begin(), tasks.end(), AsyncTaskSortPriority());
TaskHeap::reverse_iterator ti;
int current_sort = tasks.back()->get_sort() - 1;
// Since AsyncTaskSortPriority() sorts backwards (because of STL's
// push_heap semantics), we go through the task list in reverse
// order to print them forwards.
TaskHeap::reverse_iterator ti;
for (ti = tasks.rbegin(); ti != tasks.rend(); ++ti) {
AsyncTask *task = (*ti);
write_task_line(out, indent_level, task, now);

View File

@ -2044,7 +2044,7 @@ read_subfile(int index, pvector<unsigned char> &result) {
_read->seek_read(pos, buffer, num_bytes, count, eof);
while (count != 0) {
thread_consider_yield();
nassertr(count <= max_bytes, false);
nassertr(count <= (streamsize)max_bytes, false);
result.insert(result.end(), buffer, buffer + (size_t)count);
max_bytes -= (size_t)count;
pos += count;

View File

@ -627,8 +627,9 @@ set_heightfield(const Filename &filename, PNMFileType *ftype) {
reqy = max(3, (int) pow(2.0, ceil(log((double) max(2, imgheader.get_y_size() - 1)) / log(2.0))) + 1);
// If it's not a valid size, tell PNMImage to resize it.
if (reqx != imgheader.get_x_size() || reqy != imgheader.get_y_size()) {
grutil_cat.warning() << "Rescaling heightfield image " << filename
if (reqx != (unsigned int)imgheader.get_x_size() || reqy != (unsigned int)imgheader.get_y_size()) {
grutil_cat.warning()
<< "Rescaling heightfield image " << filename
<< " from " << imgheader.get_x_size() << "x" << imgheader.get_y_size()
<< " to " << reqx << "x" << reqy << " pixels.\n";
_heightfield.set_read_size(reqx, reqy);

View File

@ -447,7 +447,8 @@ void MeshDrawer::geometry(NodePath draw_node) {
// parameters.
// Frame contains u,v,u-size,v-size quadruple.
////////////////////////////////////////////////////////////////////
void MeshDrawer::link_segment(LVector3f pos, LVector4f frame,
void MeshDrawer::
link_segment(LVector3f pos, LVector4f frame,
float thickness, LVector4f color) {
assert(_render.get_error_type() == NodePath::ET_ok);
assert(_camera.get_error_type() == NodePath::ET_ok);
@ -487,9 +488,8 @@ void MeshDrawer::link_segment(LVector3f pos, LVector4f frame,
PT(Camera) camera = DCAST(Camera, _camera.node());
PT(Lens) lens = camera->get_lens();
bool start_good = lens->project(cam_start3d, cam_start2d);
bool stop_good = lens->project(cam_stop3d, cam_stop2d);
//if start_good and stop_good:
lens->project(cam_start3d, cam_start2d);
lens->project(cam_stop3d, cam_stop2d);
LVector2f dif = cam_stop2d - cam_start2d;
float rotation = atan2(dif.get_x(),dif.get_y());

View File

@ -63,11 +63,11 @@ CData() :
_video_width(1),
_video_height(1),
_video_length(1.0),
_playing(false),
_clock(0.0),
_play_rate(1.0),
_playing(false),
_loop_count(1),
_loops_total(1)
_loops_total(1),
_play_rate(1.0)
{
}
@ -82,11 +82,11 @@ CData(const CData &copy) :
_video_width(copy._video_width),
_video_height(copy._video_height),
_video_length(copy._video_length),
_playing(false),
_clock(0.0),
_play_rate(1.0),
_playing(false),
_loop_count(1),
_loops_total(1)
_loops_total(1),
_play_rate(1.0)
{
}
@ -189,8 +189,6 @@ do_recalculate_image_properties(CDWriter &cdata, const LoaderOptions &options) {
if (y_max > x_max) x_max = y_max;
}
int x_size = x_max;
int y_size = y_max;
if (Texture::get_textures_power_2() != ATS_none) {
x_max = up_to_power_2(x_max);
y_max = up_to_power_2(y_max);

View File

@ -118,7 +118,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
nassertr(fast != NULL, -1);
// Let's be strict about size mismatches, to prevent user error.
if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) {
PyErr_SetString(PyExc_ValueError, "length mismatch");
Py_DECREF(fast);
return -1;
@ -127,7 +127,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
// Get a pointer to the items, iterate over it and
// perform our magic assignment. Fast fast. Oh yeah.
PyObject** items = PySequence_Fast_ITEMS(fast);
for (int i = 0; i < attr_name.size(); ++i) {
for (size_t i = 0; i < attr_name.size(); ++i) {
PyObject* fl = PyNumber_Float(items[i]);
if (fl == NULL) {

View File

@ -127,7 +127,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
nassertr(fast != NULL, -1);
// Let's be strict about size mismatches, to prevent user error.
if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) {
PyErr_SetString(PyExc_ValueError, "length mismatch");
Py_DECREF(fast);
return -1;
@ -136,7 +136,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
// Get a pointer to the items, iterate over it and
// perform our magic assignment. Fast fast. Oh yeah.
PyObject** items = PySequence_Fast_ITEMS(fast);
for (int i = 0; i < attr_name.size(); ++i) {
for (size_t i = 0; i < attr_name.size(); ++i) {
PyObject* fl = PyNumber_Float(items[i]);
if (fl == NULL) {

View File

@ -141,7 +141,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
nassertr(fast != NULL, -1);
// Let's be strict about size mismatches, to prevent user error.
if (PySequence_Fast_GET_SIZE(fast) != attr_name.size()) {
if (PySequence_Fast_GET_SIZE(fast) != (int)attr_name.size()) {
PyErr_SetString(PyExc_ValueError, "length mismatch");
Py_DECREF(fast);
return -1;
@ -150,7 +150,7 @@ __setattr__, PyObject *self, const string &attr_name, PyObject *assign) {
// Get a pointer to the items, iterate over it and
// perform our magic assignment. Fast fast. Oh yeah.
PyObject** items = PySequence_Fast_ITEMS(fast);
for (int i = 0; i < attr_name.size(); ++i) {
for (size_t i = 0; i < attr_name.size(); ++i) {
PyObject* fl = PyNumber_Float(items[i]);
if (fl == NULL) {

View File

@ -592,15 +592,18 @@ setup(float width, int num_lines) {
switch (text_node->get_align()) {
case TextNode::A_left:
case TextNode::A_boxed_left:
// The default case.
break;
case TextNode::A_center:
case TextNode::A_boxed_center:
frame[0] = -width / 2.0;
frame[1] = width / 2.0;
break;
case TextNode::A_right:
case TextNode::A_boxed_right:
frame[0] = -width;
frame[1] = 0.0f;
break;

View File

@ -302,7 +302,7 @@ call_python_func(PyObject *function, PyObject *args) {
// Create a new Python thread state data structure, so Python can
// properly lock itself.
PyObject *result;
PyObject *result = NULL;
if (this == get_main_thread()) {
// In the main thread, just call the function.

View File

@ -62,7 +62,6 @@ FreetypeFont() {
FreetypeFont::
FreetypeFont(const FreetypeFont &copy) :
Namable(copy),
_face(copy._face),
_point_size(copy._point_size),
_requested_pixels_per_unit(copy._requested_pixels_per_unit),
_tex_pixels_per_unit(copy._tex_pixels_per_unit),
@ -71,6 +70,7 @@ FreetypeFont(const FreetypeFont &copy) :
_native_antialias(copy._native_antialias),
_line_height(copy._line_height),
_space_advance(copy._space_advance),
_face(copy._face),
_char_size(copy._char_size),
_dpi(copy._dpi),
_pixel_width(copy._pixel_width),

View File

@ -283,7 +283,7 @@ main_tick() {
// We have some memory usage on this TypeHandle. See if we
// have a collector for it.
if (!col.is_valid()) {
const char *category;
const char *category = "";
switch (mc) {
case TypeHandle::MC_singleton:
category = "Heap:Single";

View File

@ -304,6 +304,18 @@ write(ostream &out, int indent_level) const {
case A_center:
out << "A_center\n";
break;
case A_boxed_left:
out << "A_boxed_left\n";
break;
case A_boxed_right:
out << "A_boxed_right\n";
break;
case A_boxed_center:
out << "A_boxed_center\n";
break;
}
}