mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
widl: Replace sprintf with snprintf to avoid deprecation warnings on macOS.
This commit is contained in:
parent
37307535a2
commit
070e393146
Notes:
Alexandre Julliard
2024-09-19 23:03:14 +02:00
Approved-by: Rémi Bernon (@rbernon) Approved-by: Huw Davies (@huw) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6524
6 changed files with 19 additions and 18 deletions
|
@ -109,7 +109,7 @@ static const char *uuid_string(const struct uuid *uuid)
|
|||
{
|
||||
static char buf[37];
|
||||
|
||||
sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
snprintf(buf, sizeof(buf), "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
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]);
|
||||
|
||||
|
@ -199,7 +199,7 @@ static void write_fields(FILE *h, var_list_t *fields, enum name_type name_type)
|
|||
if(nameless_struct_cnt == 1) {
|
||||
name = "__C89_NAMELESSSTRUCTNAME";
|
||||
}else if(nameless_struct_i < 5 /* # of supporting macros */) {
|
||||
sprintf(buf, "__C89_NAMELESSSTRUCTNAME%d", ++nameless_struct_i);
|
||||
snprintf(buf, sizeof(buf), "__C89_NAMELESSSTRUCTNAME%d", ++nameless_struct_i);
|
||||
name = buf;
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ static void write_fields(FILE *h, var_list_t *fields, enum name_type name_type)
|
|||
if(nameless_union_cnt == 1) {
|
||||
name = "__C89_NAMELESSUNIONNAME";
|
||||
}else if(nameless_union_i < 8 /* # of supporting macros */ ) {
|
||||
sprintf(buf, "__C89_NAMELESSUNIONNAME%d", ++nameless_union_i);
|
||||
snprintf(buf, sizeof(buf), "__C89_NAMELESSUNIONNAME%d", ++nameless_union_i);
|
||||
name = buf;
|
||||
}
|
||||
}
|
||||
|
@ -1049,9 +1049,9 @@ static char *get_vtbl_entry_name(const type_t *iface, const var_t *func)
|
|||
{
|
||||
static char buff[255];
|
||||
if (is_inherited_method(iface, func))
|
||||
sprintf(buff, "%s_%s", iface->name, get_name(func));
|
||||
snprintf(buff, sizeof(buff), "%s_%s", iface->name, get_name(func));
|
||||
else
|
||||
sprintf(buff, "%s", get_name(func));
|
||||
snprintf(buff, sizeof(buff), "%s", get_name(func));
|
||||
return buff;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,10 +37,11 @@ static int indent;
|
|||
static const char *format_uuid( const struct uuid *uuid )
|
||||
{
|
||||
static char buffer[40];
|
||||
sprintf( buffer, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||
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] );
|
||||
snprintf( buffer, sizeof(buffer),
|
||||
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||
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] );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -358,7 +359,7 @@ void output_typelib_regscript( const typelib_t *typelib )
|
|||
expr = get_attrp( typelib->attrs, ATTR_ID );
|
||||
if (expr)
|
||||
{
|
||||
sprintf(id_part, "\\%d", expr->cval);
|
||||
snprintf(id_part, sizeof(id_part), "\\%d", expr->cval);
|
||||
resname = strmake("%s\\%d", typelib_name, expr->cval);
|
||||
}
|
||||
put_str( indent, "'%x' { %s = s '%%MODULE%%%s' }\n",
|
||||
|
|
|
@ -1270,7 +1270,7 @@ static unsigned int write_new_procformatstring_type(FILE *file, int indent, cons
|
|||
if (flags & IsBasetype) strcat( buffer, " base type," );
|
||||
if (flags & IsByValue) strcat( buffer, " by value," );
|
||||
if (flags & IsSimpleRef) strcat( buffer, " simple ref," );
|
||||
if (flags >> 13) sprintf( buffer + strlen(buffer), " srv size=%u,", (flags >> 13) * 8 );
|
||||
if (flags >> 13) snprintf( buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), " srv size=%u,", (flags >> 13) * 8 );
|
||||
strcpy( buffer + strlen( buffer ) - 1, " */" );
|
||||
print_file( file, indent, "NdrFcShort(0x%hx),\t%s\n", flags, buffer );
|
||||
print_file( file, indent, "NdrFcShort(0x%x), /* stack offset = %u */\n",
|
||||
|
@ -4896,7 +4896,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func )
|
|||
type_to_print = &var->declspec;
|
||||
else
|
||||
type_to_print = type_pointer_get_ref(var->declspec.type);
|
||||
sprintf(name, "_W%u", i++);
|
||||
snprintf(name, sizeof(name), "_W%u", i++);
|
||||
write_type_decl(file, type_to_print, name);
|
||||
fprintf(file, ";\n");
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ static void add_widl_version_define(void)
|
|||
if (p)
|
||||
version += atoi(p + 1);
|
||||
|
||||
sprintf(version_str, "__WIDL__=0x%x", version);
|
||||
snprintf(version_str, sizeof(version_str), "__WIDL__=0x%x", version);
|
||||
wpp_add_cmdline_define(version_str);
|
||||
}
|
||||
|
||||
|
|
|
@ -2741,7 +2741,7 @@ static void save_all_changes(msft_typelib_t *typelib)
|
|||
|
||||
expr_t *expr = get_attrp( typelib->typelib->attrs, ATTR_ID );
|
||||
if (expr)
|
||||
sprintf( typelib_id, "#%d", expr->cval );
|
||||
snprintf( typelib_id, sizeof(typelib_id), "#%d", expr->cval );
|
||||
add_output_to_resources( "TYPELIB", typelib_id );
|
||||
if (strendswith( typelib_name, "_t.res" )) /* add typelib registration */
|
||||
output_typelib_regscript( typelib->typelib );
|
||||
|
@ -2817,7 +2817,7 @@ int create_msft_typelib(typelib_t *typelib)
|
|||
* - a string representation of those
|
||||
*/
|
||||
cur_time = 2147483647;
|
||||
sprintf(info_string, "Created by WIDL version %s at %s", PACKAGE_VERSION, asctime(gmtime(&cur_time)));
|
||||
snprintf(info_string, sizeof(info_string), "Created by WIDL version %s at %s", PACKAGE_VERSION, asctime(gmtime(&cur_time)));
|
||||
set_custdata(msft, &midl_info_guid, VT_BSTR, info_string, &msft->typelib_header.CustomDataOffset);
|
||||
set_custdata(msft, &midl_time_guid, VT_UI4, &cur_time, &msft->typelib_header.CustomDataOffset);
|
||||
set_custdata(msft, &midl_version_guid, VT_UI4, &version, &msft->typelib_header.CustomDataOffset);
|
||||
|
|
|
@ -544,7 +544,7 @@ static void init_typeinfo(struct sltg_typeinfo_header *ti, const type_t *type, s
|
|||
|
||||
for (i = 0; i < hrefmap->href_count; i++)
|
||||
{
|
||||
sprintf(name, "*\\Rffff*#%x", hrefmap->href[i]);
|
||||
snprintf(name, sizeof(name), "*\\Rffff*#%x", hrefmap->href[i]);
|
||||
hrefinfo_size += 8 + 2 + strlen(name);
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ static void write_hrefmap(struct sltg_data *data, const struct sltg_hrefmap *hre
|
|||
{
|
||||
short len;
|
||||
|
||||
sprintf(name, "*\\Rffff*#%x", hrefmap->href[i]);
|
||||
snprintf(name, sizeof(name), "*\\Rffff*#%x", hrefmap->href[i]);
|
||||
len = strlen(name);
|
||||
|
||||
append_data(data, &len, sizeof(len));
|
||||
|
@ -1733,7 +1733,7 @@ static void save_all_changes(struct sltg_typelib *typelib)
|
|||
|
||||
expr_t *expr = get_attrp(typelib->typelib->attrs, ATTR_ID);
|
||||
if (expr)
|
||||
sprintf(typelib_id, "#%d", expr->cval);
|
||||
snprintf(typelib_id, sizeof(typelib_id), "#%d", expr->cval);
|
||||
add_output_to_resources("TYPELIB", typelib_id);
|
||||
if (strendswith(typelib_name, "_t.res")) /* add typelib registration */
|
||||
output_typelib_regscript(typelib->typelib);
|
||||
|
|
Loading…
Reference in a new issue