diff --git a/tools/widl/client.c b/tools/widl/client.c index 1d5940226d6..559d8c8c914 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -41,6 +41,7 @@ static FILE* client; static int indent = 0; +static void print_client( const char *format, ... ) __attribute__((format (printf, 1, 2))); static void print_client( const char *format, ... ) { va_list va; @@ -166,7 +167,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) /* declare return value '_RetVal' */ if (!is_void(type_function_get_rettype(func->type))) { - print_client(""); + print_client("%s", ""); write_type_decl_left(client, type_function_get_rettype(func->type)); fprintf(client, " _RetVal;\n"); } @@ -397,7 +398,7 @@ static void write_clientinterfacedecl(type_t *iface) print_client("{\n"); indent++; print_client("sizeof(RPC_CLIENT_INTERFACE),\n"); - print_client("{{0x%08lx,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n", + print_client("{{0x%08x,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n", uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver)); diff --git a/tools/widl/header.h b/tools/widl/header.h index 6ac7cb0ae65..7829e094c62 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -34,8 +34,8 @@ extern int is_declptr(const type_t *t); extern const char* get_name(const var_t *v); extern void write_type_left(FILE *h, type_t *t, int declonly); extern void write_type_right(FILE *h, type_t *t, int is_field); -extern void write_type_def_or_decl(FILE *h, type_t *t, int is_field, const char *fmt, ...); -extern void write_type_decl(FILE *f, type_t *t, const char *fmt, ...); +extern void write_type_def_or_decl(FILE *h, type_t *t, int is_field, const char *fmt, ...) __attribute__((format (printf, 4, 5))); +extern void write_type_decl(FILE *f, type_t *t, const char *fmt, ...) __attribute__((format (printf, 3, 4))); extern void write_type_decl_left(FILE *f, type_t *t); extern int needs_space_after(type_t *t); extern int is_object(const attr_list_t *list); diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c index 0dcb7378d0a..615b2a1dfe3 100644 --- a/tools/widl/proxy.c +++ b/tools/widl/proxy.c @@ -50,6 +50,7 @@ static int indent = 0; /* FIXME: support generation of stubless proxies */ +static void print_proxy( const char *format, ... ) __attribute__((format (printf, 1, 2))); static void print_proxy( const char *format, ... ) { va_list va; @@ -325,7 +326,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, print_proxy( "struct __proxy_frame __f, * const __frame = &__f;\n" ); /* local variables */ if (has_ret) { - print_proxy( "" ); + print_proxy( "%s", "" ); write_type_decl_left(proxy, type_function_get_rettype(func->type)); print_proxy( " _RetVal;\n"); } @@ -481,8 +482,7 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas, print_proxy("*_pdwStubPhase = STUB_CALL_SERVER;\n"); fprintf(proxy, "\n"); - print_proxy(""); - if (has_ret) fprintf(proxy, "__frame->_RetVal = "); + print_proxy( "%s", has_ret ? "__frame->_RetVal = " : "" ); if (cas) fprintf(proxy, "%s_%s_Stub", iface->name, cas); else fprintf(proxy, "__frame->_This->lpVtbl->%s", get_name(func)); fprintf(proxy, "(__frame->_This"); @@ -651,7 +651,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) print_proxy( "static const CINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n", count, iface->name); print_proxy( "{\n"); indent++; - print_proxy( "{\n", iface->name); + print_proxy( "{\n"); indent++; print_proxy( "&IID_%s,\n", iface->name); indent--; @@ -686,7 +686,7 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset) print_proxy( "%d,\n", count); print_proxy( "&%s_table[-3],\n", iface->name); indent--; - print_proxy( "},\n", iface->name); + print_proxy( "},\n"); print_proxy( "{\n"); indent++; print_proxy( "CStdStubBuffer_%s\n", need_delegation_indirect(iface) ? "DELEGATING_METHODS" : "METHODS"); diff --git a/tools/widl/server.c b/tools/widl/server.c index a64424514bd..ff61a8afced 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -40,6 +40,7 @@ static FILE* server; static int indent = 0; +static void print_server(const char *format, ...) __attribute__((format (printf, 1, 2))); static void print_server(const char *format, ...) { va_list va; @@ -155,11 +156,9 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset) assign_stub_out_args(server, indent, func, "__frame->"); /* Call the real server function */ - if (!is_void(type_function_get_rettype(func->type))) - print_server("__frame->_RetVal = "); - else - print_server(""); - fprintf(server, "%s%s", prefix_server, get_name(func)); + print_server("%s%s%s", + is_void(type_function_get_rettype(func->type)) ? "" : "__frame->_RetVal = ", + prefix_server, get_name(func)); if (type_get_function_args(func->type)) { @@ -335,7 +334,7 @@ static void write_serverinterfacedecl(type_t *iface) print_server("{\n"); indent++; print_server("sizeof(RPC_SERVER_INTERFACE),\n"); - print_server("{{0x%08lx,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n", + print_server("{{0x%08x,0x%04x,0x%04x,{0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x}},{%d,%d}},\n", uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1], uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7], MAJORVERSION(ver), MINORVERSION(ver)); diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 6929135fb01..2ce138552fe 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -551,6 +551,7 @@ static const char *get_context_handle_type_name(const type_t *type) } \ while (0) +static void print_file(FILE *file, int indent, const char *format, ...) __attribute__((format (printf, 3, 4))); static void print_file(FILE *file, int indent, const char *format, ...) { va_list va; @@ -824,8 +825,8 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *structure, print_file(file, 2, "0x%x, /* Corr desc: constant, val = %ld */\n", RPC_FC_CONSTANT_CONFORMANCE, expr->cval); - print_file(file, 2, "0x%x,\n", expr->cval & ~USHRT_MAX); - print_file(file, 2, "NdrFcShort(0x%x),\n", expr->cval & USHRT_MAX); + print_file(file, 2, "0x%lx,\n", expr->cval >> 16); + print_file(file, 2, "NdrFcShort(0x%lx),\n", expr->cval & USHRT_MAX); return 4; } @@ -1263,11 +1264,11 @@ static void write_user_tfs(FILE *file, type_t *type, unsigned int *tfsoff) print_file(file, 2, "0x%x,\t/* Alignment= %d, Flags= %02x */\n", flags | (align - 1), align - 1, flags); print_file(file, 2, "NdrFcShort(0x%hx),\t/* Function offset= %hu */\n", funoff, funoff); - print_file(file, 2, "NdrFcShort(0x%lx),\t/* %lu */\n", size, size); - print_file(file, 2, "NdrFcShort(0x%lx),\t/* %lu */\n", usize, usize); + print_file(file, 2, "NdrFcShort(0x%x),\t/* %u */\n", size, size); + print_file(file, 2, "NdrFcShort(0x%x),\t/* %u */\n", usize, usize); *tfsoff += 8; reloff = absoff - *tfsoff; - print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%lu) */\n", reloff, reloff, absoff); + print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n", reloff, reloff, absoff); *tfsoff += 2; } @@ -1309,7 +1310,7 @@ static void write_member_type(FILE *file, const type_t *cont, print_file(file, 2, "0x4c,\t/* FC_EMBEDDED_COMPLEX */\n"); /* FIXME: actually compute necessary padding */ print_file(file, 2, "0x0,\t/* FIXME: padding */\n"); - print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%lu) */\n", + print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n", reloff, reloff, absoff); *tfsoff += 4; } @@ -1917,12 +1918,12 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t { if (real_type == RPC_FC_LGFARRAY || real_type == RPC_FC_LGVARRAY) { - print_file(file, 2, "NdrFcLong(0x%x),\t/* %lu */\n", size, size); + print_file(file, 2, "NdrFcLong(0x%x),\t/* %u */\n", size, size); *typestring_offset += 4; } else { - print_file(file, 2, "NdrFcShort(0x%x),\t/* %lu */\n", size, size); + print_file(file, 2, "NdrFcShort(0x%x),\t/* %u */\n", size, size); *typestring_offset += 2; } @@ -1939,16 +1940,16 @@ static unsigned int write_array_tfs(FILE *file, const attr_list_t *attrs, type_t if (real_type == RPC_FC_LGVARRAY) { - print_file(file, 2, "NdrFcLong(0x%x),\t/* %lu */\n", dim, dim); + print_file(file, 2, "NdrFcLong(0x%x),\t/* %u */\n", dim, dim); *typestring_offset += 4; } else { - print_file(file, 2, "NdrFcShort(0x%x),\t/* %lu */\n", dim, dim); + print_file(file, 2, "NdrFcShort(0x%x),\t/* %u */\n", dim, dim); *typestring_offset += 2; } - print_file(file, 2, "NdrFcShort(0x%x),\t/* %lu */\n", elsize, elsize); + print_file(file, 2, "NdrFcShort(0x%x),\t/* %u */\n", elsize, elsize); *typestring_offset += 2; } @@ -2115,7 +2116,7 @@ static unsigned int write_struct_tfs(FILE *file, type_t *type, { unsigned int absoff = array->type->typestring_offset; short reloff = absoff - *tfsoff; - print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%lu) */\n", + print_file(file, 2, "NdrFcShort(0x%hx),\t/* Offset= %hd (%u) */\n", reloff, reloff, absoff); *tfsoff += 2; } @@ -2348,7 +2349,7 @@ static unsigned int write_union_tfs(FILE *file, type_t *type, unsigned int *tfso /* MIDL doesn't check for duplicate cases, even though that seems like a reasonable thing to do, it just dumps them to the TFS like we're going to do here. */ - print_file(file, 2, "NdrFcLong(0x%x),\t/* %d */\n", c->cval, c->cval); + print_file(file, 2, "NdrFcLong(0x%lx),\t/* %ld */\n", c->cval, c->cval); *tfsoff += 4; write_branch_type(file, ft, tfsoff); } @@ -2402,7 +2403,7 @@ static unsigned int write_ip_tfs(FILE *file, const attr_list_t *attrs, type_t *t print_start_tfs_comment(file, type, start_offset); print_file(file, 2, "0x2f,\t/* FC_IP */\n"); print_file(file, 2, "0x5a,\t/* FC_CONSTANT_IID */\n"); - print_file(file, 2, "NdrFcLong(0x%08lx),\n", uuid->Data1); + print_file(file, 2, "NdrFcLong(0x%08x),\n", uuid->Data1); print_file(file, 2, "NdrFcShort(0x%04x),\n", uuid->Data2); print_file(file, 2, "NdrFcShort(0x%04x),\n", uuid->Data3); for (i = 0; i < 8; ++i) @@ -2964,11 +2965,9 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, print_file(file, indent, "{\n"); print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); print_file(file, indent, "}\n"); - if (pass == PASS_IN || pass == PASS_RETURN) - print_file(file, indent, ""); - else - print_file(file, indent, "*"); - fprintf(file, "%s%s", local_var_prefix, varname); + print_file(file, indent, "%s%s%s", + (pass == PASS_IN || pass == PASS_RETURN) ? "" : "*", + local_var_prefix, varname); if (pass == PASS_IN && is_ptr(type)) fprintf(file, " = ("); else @@ -3360,7 +3359,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) /* declare return value '_RetVal' */ if (!is_void(type_function_get_rettype(func->type))) { - print_file(file, indent, ""); + print_file(file, indent, "%s", ""); write_type_decl_left(file, type_function_get_rettype(func->type)); fprintf(file, " _RetVal;\n"); } @@ -3384,7 +3383,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) if (!in_attr && !is_conformant_array(var->type) && !is_string) { type_t *type_to_print; - print_file(file, indent, ""); + print_file(file, indent, "%s", ""); if (var->type->declarray) type_to_print = var->type; else @@ -3393,7 +3392,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) fprintf(file, ";\n"); } - print_file(file, indent, ""); + print_file(file, indent, "%s", ""); write_type_decl_left(file, var->type); fprintf(file, " "); if (var->type->declarray) {