Give functions that use printf style formatting GCC format attributes so if incorrect formatting is used the compiler will warn of this.

found & fixed 2x incorrect formatting args.
This commit is contained in:
2010-12-04 11:44:56 +00:00
parent 471d304df1
commit 0271ad6322
13 changed files with 49 additions and 21 deletions

View File

@@ -294,7 +294,11 @@ int modifier_couldBeCage(struct Scene *scene, struct ModifierData *md)
int modifier_isCorrectableDeformed(struct ModifierData *md);
int modifier_sameTopology(ModifierData *md);
int modifier_isEnabled(struct Scene *scene, struct ModifierData *md, int required_mode);
void modifier_setError(struct ModifierData *md, const char *format, ...);
void modifier_setError(struct ModifierData *md, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)));
#endif
;
void modifiers_foreachObjectLink(struct Object *ob,
ObjectWalkFunc walk,

View File

@@ -45,7 +45,11 @@ void BKE_reports_init(ReportList *reports, int flag);
void BKE_reports_clear(ReportList *reports);
void BKE_report(ReportList *reports, ReportType type, const char *message);
void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...);
void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)));
#endif
;
void BKE_reports_prepend(ReportList *reports, const char *prepend);
void BKE_reports_prependf(ReportList *reports, const char *prepend, ...);

View File

@@ -75,7 +75,11 @@ void BLI_dynstr_nappend (DynStr *ds, const char *cstr, int len);
* @param ds The DynStr to append to.
* @param format The printf format string to use.
*/
void BLI_dynstr_appendf (DynStr *ds, const char *format, ...);
void BLI_dynstr_appendf (DynStr *ds, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)));
#endif
;
void BLI_dynstr_vappendf (DynStr *ds, const char *format, va_list args);
/**

View File

@@ -102,13 +102,21 @@ char *BLI_replacestr(char *str, const char *oldText, const char *newText);
/*
* Replacement for snprintf
*/
int BLI_snprintf(char *buffer, size_t count, const char *format, ...);
int BLI_snprintf(char *buffer, size_t count, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)));
#endif
;
/*
* Print formatted string into a newly mallocN'd string
* and return it.
*/
char *BLI_sprintfN(const char *format, ...);
char *BLI_sprintfN(const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)));
#endif
;
/**
* Compare two strings

View File

@@ -928,8 +928,16 @@ void RNA_parameter_length_set_data(ParameterList *parms, PropertyRNA *parm, void
int RNA_function_call(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms);
int RNA_function_call_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, ParameterList *parms);
int RNA_function_call_direct(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...);
int RNA_function_call_direct_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...);
int RNA_function_call_direct(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 5, 6)));
#endif
;
int RNA_function_call_direct_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 5, 6)));
#endif
;
int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args);
int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args);

View File

@@ -224,7 +224,7 @@ StructRNA *rna_IDPropertyGroup_register(const bContext *C, ReportList *reports,
* owns the string pointer which it could potentually free while blender
* is running. */
if(strlen(identifier) >= sizeof(((IDProperty *)NULL)->name)) {
BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is %d.", identifier, sizeof(((IDProperty *)NULL)->name));
BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(((IDProperty *)NULL)->name));
return NULL;
}

View File

@@ -3771,7 +3771,7 @@ char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
BLI_dynstr_appendf(dynstr, "'%s'", identifier);
}
else {
BLI_dynstr_appendf(dynstr, "'<UNKNOWN ENUM>'", identifier);
BLI_dynstr_append(dynstr, "'<UNKNOWN ENUM>'");
}
break;
}

View File

@@ -173,7 +173,7 @@ static StructRNA *rna_KeyingSetInfo_register(const bContext *C, ReportList *repo
return NULL;
if (strlen(identifier) >= sizeof(dummyksi.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering keying set info class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyksi.idname));
BKE_reportf(reports, RPT_ERROR, "registering keying set info class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyksi.idname));
return NULL;
}

View File

@@ -962,17 +962,17 @@ static char *rna_VertexGroupElement_path(PointerRNA *ptr)
static char *rna_MeshFace_path(PointerRNA *ptr)
{
return BLI_sprintfN("faces[%d]", (MFace*)ptr->data - ((Mesh*)ptr->id.data)->mface);
return BLI_sprintfN("faces[%d]", (int)((MFace*)ptr->data - ((Mesh*)ptr->id.data)->mface));
}
static char *rna_MeshEdge_path(PointerRNA *ptr)
{
return BLI_sprintfN("edges[%d]", (MEdge*)ptr->data - ((Mesh*)ptr->id.data)->medge);
return BLI_sprintfN("edges[%d]", (int)((MEdge*)ptr->data - ((Mesh*)ptr->id.data)->medge));
}
static char *rna_MeshVertex_path(PointerRNA *ptr)
{
return BLI_sprintfN("vertices[%d]", (MVert*)ptr->data - ((Mesh*)ptr->id.data)->mvert);
return BLI_sprintfN("vertices[%d]", (int)((MVert*)ptr->data - ((Mesh*)ptr->id.data)->mvert));
}
static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr)
@@ -1015,7 +1015,7 @@ static char *rna_MeshColor_path(PointerRNA *ptr)
static char *rna_MeshSticky_path(PointerRNA *ptr)
{
return BLI_sprintfN("sticky[%d]", (MSticky*)ptr->data - ((Mesh*)ptr->id.data)->msticky);
return BLI_sprintfN("sticky[%d]", (int)((MSticky*)ptr->data - ((Mesh*)ptr->id.data)->msticky));
}
static char *rna_MeshIntPropertyLayer_path(PointerRNA *ptr)

View File

@@ -124,7 +124,7 @@ static StructRNA *rna_RenderEngine_register(const bContext *C, ReportList *repor
return NULL;
if(strlen(identifier) >= sizeof(dummyet.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyet.idname));
BKE_reportf(reports, RPT_ERROR, "registering render engine class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyet.idname));
return NULL;
}

View File

@@ -180,7 +180,7 @@ static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, voi
return NULL;
if(strlen(identifier) >= sizeof(dummypt.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummypt.idname));
BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummypt.idname));
return NULL;
}
@@ -283,7 +283,7 @@ static StructRNA *rna_Header_register(const bContext *C, ReportList *reports, vo
return NULL;
if(strlen(identifier) >= sizeof(dummyht.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyht.idname));
BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyht.idname));
return NULL;
}
@@ -401,7 +401,7 @@ static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void
return NULL;
if(strlen(identifier) >= sizeof(dummymt.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering menu class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummymt.idname));
BKE_reportf(reports, RPT_ERROR, "registering menu class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummymt.idname));
return NULL;
}

View File

@@ -854,7 +854,7 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
}
if(strlen(identifier) >= sizeof(dummyop.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyop.idname));
BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyop.idname));
return NULL;
}
@@ -924,7 +924,7 @@ static StructRNA *rna_MacroOperator_register(const bContext *C, ReportList *repo
}
if(strlen(identifier) >= sizeof(dummyop.idname)) {
BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d.", identifier, sizeof(dummyop.idname));
BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyop.idname));
return NULL;
}

View File

@@ -625,7 +625,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re
/* send the OnSave event */
for (li= G.main->library.first; li; li= li->id.next) {
if (strcmp(li->filepath, di) == 0) {
BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%f'", di);
BKE_reportf(reports, RPT_ERROR, "Can't overwrite used library '%.200s'", di);
return -1;
}
}