diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-29 10:25:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-29 10:25:22 +0400 |
commit | 1777a69818610d4ed8a93f661a45219d97e7f6c5 (patch) | |
tree | bbfb0b35629e94ffd727f4a8b98fbf6cbebdaa36 /source | |
parent | ab41583bc2be591c0af921b243158e43a94505d7 (diff) |
misc minor edits.
- pass string size to BLI_timestr() to avoid possible buffer overrun.
- quiet warning for mingw.
- include guards for windows utf conversion funcs.
- fix for mistage in edge-angle-selection check.
- some style cleanup.
Diffstat (limited to 'source')
20 files changed, 48 insertions, 50 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 51c46bcc235..0c988ac45fc 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -235,19 +235,19 @@ struct DerivedMesh { * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ - void *(*getVertData)(DerivedMesh * dm, int index, int type); - void *(*getEdgeData)(DerivedMesh * dm, int index, int type); - void *(*getTessFaceData)(DerivedMesh * dm, int index, int type); - void *(*getPolyData)(DerivedMesh * dm, int index, int type); + void *(*getVertData)(DerivedMesh *dm, int index, int type); + void *(*getEdgeData)(DerivedMesh *dm, int index, int type); + void *(*getTessFaceData)(DerivedMesh *dm, int index, int type); + void *(*getPolyData)(DerivedMesh *dm, int index, int type); /** Return a pointer to the entire array of vert/edge/face custom data * from the derived mesh (this gives a pointer to the actual data, not * a copy) */ - void *(*getVertDataArray)(DerivedMesh * dm, int type); - void *(*getEdgeDataArray)(DerivedMesh * dm, int type); - void *(*getTessFaceDataArray)(DerivedMesh * dm, int type); - void *(*getPolyDataArray)(DerivedMesh * dm, int type); + void *(*getVertDataArray)(DerivedMesh *dm, int type); + void *(*getEdgeDataArray)(DerivedMesh *dm, int type); + void *(*getTessFaceDataArray)(DerivedMesh *dm, int type); + void *(*getPolyDataArray)(DerivedMesh *dm, int type); /** Retrieves the base CustomData structures for * verts/edges/tessfaces/loops/facdes*/ diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index c9034cfe7bb..843c3d66e58 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1601,7 +1601,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d RenderStats *stats = re ? RE_GetStats(re) : NULL; if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { - BLI_timestr(stats->lastframetime, text); + BLI_timestr(stats->lastframetime, text, sizeof(text)); BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s" : "%s", text); } diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 3bc9d733254..770a4c0e3ab 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -150,7 +150,7 @@ __attribute__((warn_unused_result)) __attribute__((nonnull)) #endif ; -void BLI_timestr(double _time, char *str) +void BLI_timestr(double _time, char *str, size_t maxlen) #ifdef __GNUC__ __attribute__((nonnull)) #endif diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 906a3095f91..ba914944733 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -490,22 +490,20 @@ int BLI_natstrcmp(const char *s1, const char *s2) return 0; } -void BLI_timestr(double _time, char *str) +void BLI_timestr(double _time, char *str, size_t maxlen) { /* format 00:00:00.00 (hr:min:sec) string has to be 12 long */ int hr = ( (int) _time) / (60 * 60); int min = (((int) _time) / 60 ) % 60; - int sec = ( (int) (_time)) % 60; + int sec = ( (int) _time) % 60; int hun = ( (int) (_time * 100.0)) % 100; - + if (hr) { - sprintf(str, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun); + BLI_snprintf(str, maxlen, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun); } else { - sprintf(str, "%.2d:%.2d.%.2d", min, sec, hun); + BLI_snprintf(str, maxlen, "%.2d:%.2d.%.2d", min, sec, hun); } - - str[11] = 0; } /* determine the length of a fixed-size string */ diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index fe8f3c20ab4..0b8cc126a86 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -602,7 +602,7 @@ size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf) * * Return value: a pointer to the found character or %NULL. **/ -char * BLI_str_find_prev_char_utf8(const char *str, const char *p) +char *BLI_str_find_prev_char_utf8(const char *str, const char *p) { for (--p; p >= str; --p) { if ((*p & 0xc0) != 0x80) { diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 293b992f219..61c220e4bbe 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -148,20 +148,20 @@ public: #endif void translate_Animations(COLLADAFW::Node * Node, - std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map, - std::multimap<COLLADAFW::UniqueId, Object*>& object_map, - std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map); + std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map, + std::multimap<COLLADAFW::UniqueId, Object*>& object_map, + std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map); AnimMix* get_animation_type( const COLLADAFW::Node * node, std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map ); - void apply_matrix_curves(Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, + void apply_matrix_curves(Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm ); - void add_bone_animation_sampled(Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm); + void add_bone_animation_sampled(Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm); void Assign_transform_animations(COLLADAFW::Transformation* transform, - const COLLADAFW::AnimationList::AnimationBinding * binding, - std::vector<FCurve*>* curves, bool is_joint, char * joint_path); + const COLLADAFW::AnimationList::AnimationBinding *binding, + std::vector<FCurve*>* curves, bool is_joint, char *joint_path); void Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char * anim_type); void Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const char * anim_type); diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index 2a8f1a65e21..bfbf7433d97 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -113,7 +113,7 @@ private: void fix_leaf_bones(); - void set_pose ( Object * ob_arm, COLLADAFW::Node * root_node, const char *parentname, float parent_mat[4][4]); + void set_pose( Object *ob_arm, COLLADAFW::Node *root_node, const char *parentname, float parent_mat[4][4]); #if 0 diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 82d1c7883e1..7c454445e4f 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -435,7 +435,7 @@ void ExecutionGroup::printBackgroundStats(void) fprintf(stdout, "Mem:%.2fM (%.2fM, Peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory); - BLI_timestr(execution_time, timestr); + BLI_timestr(execution_time, timestr, sizeof(timestr)); printf("| Elapsed %s ", timestr); printf("| Tree %s, Tile %d-%d ", this->m_bTree->id.name + 2, this->m_chunksFinished, this->m_numberOfChunks); diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index a0d10db94ea..c3383db81df 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -407,7 +407,7 @@ typedef struct bAnimChannelType { * with type being sizeof(ptr_data) which should be fine for runtime use... * - assume that setting has been checked to be valid for current context */ - void *(*setting_ptr)(bAnimListElem * ale, int setting, short *type); + void *(*setting_ptr)(bAnimListElem *ale, int setting, short *type); } bAnimChannelType; /* ------------------------ Drawing API -------------------------- */ diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 05c3af40a29..9634acd701a 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -394,7 +394,7 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) /* Format time string */ char time_str[30]; double time = PIL_check_seconds_timer() - timer; - BLI_timestr(time, time_str); + BLI_timestr(time, time_str, sizeof(time_str)); /* Show bake info */ BKE_reportf(op->reports, RPT_INFO, "Bake complete! (%s)", time_str); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1268d577f44..365ac02d15b 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -311,7 +311,7 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str) spos += sprintf(spos, IFACE_("Blur %d "), rs->curblur); } - BLI_timestr(rs->lastframetime, info_time_str); + BLI_timestr(rs->lastframetime, info_time_str, sizeof(info_time_str)); spos += sprintf(spos, IFACE_("Time:%s "), info_time_str); if (rs->curfsa) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4478d68d3be..741a39a2642 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -442,7 +442,7 @@ static void paint_redraw(const bContext *C, PaintOperation *pop, int final) } } -static PaintOperation * texture_paint_init(bContext *C, wmOperator *op, const wmEvent *event) +static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); ToolSettings *settings = scene->toolsettings; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 4d4c616e2f4..b448e0589ae 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2671,8 +2671,8 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS /* special case, this is useful to show when vertes connected to this edge via a * face are being transformed */ BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) || - BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT) || - BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) || + BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) || + BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) || BM_elem_flag_test(l_b->prev->v, BM_ELEM_SELECT) ))) { diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 64ec658f0db..96f7a68d669 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -81,7 +81,7 @@ typedef struct anim_index_builder { struct anim_index_entry *entry); } anim_index_builder; -anim_index_builder * IMB_index_builder_create(const char *name); +anim_index_builder *IMB_index_builder_create(const char *name); void IMB_index_builder_add_entry( anim_index_builder * fp, int frameno, unsigned long long seek_pos, @@ -118,7 +118,7 @@ void IMB_free_indices(struct anim *anim); struct anim *IMB_anim_open_proxy( struct anim *anim, IMB_Proxy_Size preview_size); -struct anim_index * IMB_anim_open_index( +struct anim_index *IMB_anim_open_index( struct anim *anim, IMB_Timecode_Type tc); int IMB_proxy_size_to_array_index(IMB_Proxy_Size pr_size); diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h index 11e6d4a5708..3d308ba1ff1 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h @@ -171,9 +171,9 @@ public: void setHasAlphaFlag(bool b); void setUserVersion(int version); - void mipmap(Image * img, uint f, uint m); + void mipmap(Image *img, uint f, uint m); void *readData(uint &size); - // void mipmap(FloatImage * img, uint f, uint m); + // void mipmap(FloatImage *img, uint f, uint m); void printInfo() const; diff --git a/source/blender/imbuf/intern/dds/Image.h b/source/blender/imbuf/intern/dds/Image.h index 81074fba6b7..658f01deaec 100644 --- a/source/blender/imbuf/intern/dds/Image.h +++ b/source/blender/imbuf/intern/dds/Image.h @@ -56,9 +56,9 @@ public: void allocate(uint w, uint h); #if 0 - bool load(const char * name); + bool load(const char *name); - void wrap(void * data, uint w, uint h); + void wrap(void *data, uint w, uint h); void unwrap(); #endif diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h index 2bb1864e49d..e841e696833 100644 --- a/source/blender/imbuf/intern/dds/PixelFormat.h +++ b/source/blender/imbuf/intern/dds/PixelFormat.h @@ -80,7 +80,7 @@ } // Get pixel component shift and size given its mask. - inline void maskShiftAndSize(uint mask, uint * shift, uint * size) + inline void maskShiftAndSize(uint mask, uint *shift, uint *size) { if (!mask) { *shift = 0; diff --git a/source/blender/makesrna/intern/rna_test.c b/source/blender/makesrna/intern/rna_test.c index 1f5a4ff7f92..22b6f323647 100644 --- a/source/blender/makesrna/intern/rna_test.c +++ b/source/blender/makesrna/intern/rna_test.c @@ -57,12 +57,12 @@ (void)0 #define DEF_GET_SET(type, arr) \ - void rna_Test_ ## arr ## _get(PointerRNA * ptr, type * values) \ + void rna_Test_ ## arr ## _get(PointerRNA *ptr, type * values) \ { \ memcpy(values, arr, sizeof(arr)); \ } \ - \ - void rna_Test_ ## arr ## _set(PointerRNA * ptr, const type * values) \ + \ + void rna_Test_ ## arr ## _set(PointerRNA *ptr, const type * values) \ { \ memcpy(arr, values, sizeof(arr)); \ } \ @@ -73,14 +73,14 @@ { \ return arr ## _len; \ } \ - \ - static int rna_Test_ ## arr ## _set_length(PointerRNA * ptr, int length) \ + \ + static int rna_Test_ ## arr ## _set_length(PointerRNA *ptr, int length) \ { \ if (length > max) \ return 0; \ - \ + \ arr ## _len = length; \ - \ + \ return 1; \ } \ (void)0 diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 7b325d51787..f8d8ffdfcd6 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2357,12 +2357,12 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie render_time = re->i.lastframetime; re->i.lastframetime = PIL_check_seconds_timer() - re->i.starttime; - BLI_timestr(re->i.lastframetime, name); + BLI_timestr(re->i.lastframetime, name, sizeof(name)); printf(" Time: %s", name); BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS); - BLI_timestr(re->i.lastframetime - render_time, name); + BLI_timestr(re->i.lastframetime - render_time, name, sizeof(name)); printf(" (Saving: %s)\n", name); fputc('\n', stdout); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 9cb46632198..f8cd154df35 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -956,7 +956,7 @@ void wm_autosave_location(char *filepath) { char pidstr[32]; #ifdef WIN32 - char *savedir; + const char *savedir; #endif BLI_snprintf(pidstr, sizeof(pidstr), "%d.blend", abs(getpid())); |