0999158088e0fb3715eb27703c8c4f7123d77144 galt Mon Sep 21 16:51:20 2015 -0700 added GNU-C attributes to function declarations in src/inc, src/hg/inc, and some CGIs so that the compiler can catch errors where the parameter list given by the user does not match their format string. These var-args functions are like printf. diff --git src/inc/jsonWrite.h src/inc/jsonWrite.h index b5efb25..7079f8b 100644 --- src/inc/jsonWrite.h +++ src/inc/jsonWrite.h @@ -55,32 +55,37 @@ /* Print out the jsony type link to another object with a numerical id. objRoot will start * and end with a '/' and may have additional slashes in this usage. Var may be NULL */ void jsonWriteListStart(struct jsonWrite *jw, char *var); /* Start an array in JSON. Var may be NULL */ void jsonWriteListEnd(struct jsonWrite *jw); /* End an array in JSON */ void jsonWriteObjectStart(struct jsonWrite *jw, char *var); /* Print start of object, preceded by tag if var is non-NULL. */ void jsonWriteObjectEnd(struct jsonWrite *jw); /* End object in JSON */ -void jsonWriteStringf(struct jsonWrite *jw, char *var, char *format, ...); +void jsonWriteStringf(struct jsonWrite *jw, char *var, char *format, ...) /* Write "var": "val" where val is jsonStringEscape'd formatted string. */ +#if defined(__GNUC__) +__attribute__((format(printf, 3, 4))) +#endif +; + void jsonWriteBoolean(struct jsonWrite *jw, char *var, boolean val); /* Write out "var": true or "var": false depending on val (no quotes around true/false). */ void jsonWriteValueLabelList(struct jsonWrite *jw, char *var, struct slPair *pairList); /* Print out a named list of {"value": "name>", "label": "val>"} objects. */ void jsonWriteSlNameList(struct jsonWrite *jw, char *var, struct slName *slnList); /* Print out a named list of strings from slnList. */ void jsonWriteAppend(struct jsonWrite *jwA, char *var, struct jsonWrite *jwB); /* Append jwB's contents to jwA's. If jwB is non-NULL, it must be fully closed (no unclosed * list or object). If var is non-NULL, write it out as a tag before appending. * If both var and jwB are NULL, leave jwA unchanged. */