Merge branch 'size_t-conversions' into 'main'

Fix various implicit conversions from size_t to smaller types

See merge request GNOME/glib!4023
This commit is contained in:
Emmanuele Bassi 2024-04-25 14:03:17 +00:00
commit 18cd1590c3
52 changed files with 170 additions and 137 deletions

View File

@ -666,8 +666,8 @@ const gchar *
g_application_command_line_getenv (GApplicationCommandLine *cmdline,
const gchar *name)
{
gint length = strlen (name);
gint i;
size_t length = strlen (name);
size_t i;
/* TODO: expand on windows */
if (cmdline->priv->environ)

View File

@ -1373,7 +1373,7 @@ dump_method (const GDBusMethodInfo *o,
{
guint n;
guint m;
guint name_len;
size_t name_len;
guint total_num_args;
for (n = 0; o->annotations != NULL && o->annotations[n] != NULL; n++)

View File

@ -3822,8 +3822,8 @@ static gboolean
namespace_rule_matches (const gchar *namespace,
const gchar *name)
{
gint len_namespace;
gint len_name;
size_t len_namespace;
size_t len_name;
len_namespace = strlen (namespace);
len_name = strlen (name);
@ -3841,7 +3841,7 @@ static gboolean
path_rule_matches (const gchar *path_a,
const gchar *path_b)
{
gint len_a, len_b;
size_t len_a, len_b;
len_a = strlen (path_a);
len_b = strlen (path_b);

View File

@ -543,7 +543,8 @@ match_matches (GDBusDaemon *daemon,
{
MatchElement *element;
Name *name;
int i, len, len2;
int i;
size_t len, len2;
const char *value;
int check_type;

View File

@ -2852,7 +2852,7 @@ append_value_to_blob (GVariant *value,
const gchar *signature;
child = g_variant_get_child_value (value, 0);
signature = g_variant_get_type_string (child);
g_memory_buffer_put_byte (mbuf, strlen (signature));
g_memory_buffer_put_byte (mbuf, (guint8) strlen (signature)); /* signature is already validated to be this short */
g_memory_buffer_put_string (mbuf, signature);
g_memory_buffer_put_byte (mbuf, '\0');
if (!append_value_to_blob (child,

View File

@ -113,7 +113,7 @@ is_valid_name (const gchar *start,
gboolean
g_dbus_is_name (const gchar *string)
{
guint len;
size_t len;
gboolean ret;
const gchar *s;

View File

@ -239,7 +239,7 @@ static const char *
match_prefix (const char *path,
const char *prefix)
{
int prefix_len;
size_t prefix_len;
prefix_len = strlen (prefix);
if (strncmp (path, prefix, prefix_len) != 0)

View File

@ -345,7 +345,7 @@ init_completion (GFilenameCompleter *completer,
GFile *file, *parent;
char *basename;
char *t;
int len;
size_t len;
*basename_out = NULL;

View File

@ -89,7 +89,7 @@ prompt_for (const char *prompt, const char *default_value, gboolean echo)
gboolean restore_flags;
#endif
char data[256];
int len;
size_t len;
if (default_value && *default_value != 0)
g_print ("%s [%s]: ", prompt, default_value);

View File

@ -42,10 +42,10 @@ static const GOptionEntry entries[] = {
static char *
hex_unescape (const char *str)
{
int i;
size_t i;
char *unescaped_str, *p;
unsigned char c;
int len;
size_t len;
len = strlen (str);
unescaped_str = g_malloc (len + 1);

View File

@ -680,7 +680,7 @@ key_state_serialise (KeyState *state)
if (state->l10n_context)
{
gint len;
size_t len;
/* Contextified messages are supported by prepending
* the context, followed by '\004' to the start of the

View File

@ -479,7 +479,7 @@ static const char *
match_prefix (const char *path,
const char *prefix)
{
int prefix_len;
size_t prefix_len;
prefix_len = strlen (prefix);
if (strncmp (path, prefix, prefix_len) != 0)

View File

@ -83,7 +83,7 @@ list_resource (GResource *resource,
gint i;
gchar *child;
GError *error = NULL;
gint len;
size_t len;
children = g_resource_enumerate_children (resource, path, 0, &error);
if (error)

View File

@ -352,7 +352,7 @@ g_resource_find_overlay (const gchar *path,
/* This is a null-terminated array of replacement strings (with '=' inside) */
static const gchar * const *overlay_dirs;
gboolean res = FALSE;
gint path_len = -1;
size_t path_len = 0;
gint i;
/* We try to be very fast in case there are no overlays. Otherwise,
@ -449,9 +449,9 @@ g_resource_find_overlay (const gchar *path,
for (i = 0; overlay_dirs[i]; i++)
{
const gchar *src;
gint src_len;
size_t src_len;
const gchar *dst;
gint dst_len;
size_t dst_len;
gchar *candidate;
{
@ -466,7 +466,7 @@ g_resource_find_overlay (const gchar *path,
/* hold off on dst_len because we will probably fail the checks below */
}
if (path_len == -1)
if (i == 0)
path_len = strlen (path);
/* The entire path is too short to match the source */

View File

@ -354,7 +354,7 @@ static const char *
match_prefix (const char *path,
const char *prefix)
{
int prefix_len;
size_t prefix_len;
prefix_len = strlen (prefix);
if (strncmp (path, prefix, prefix_len) != 0)

View File

@ -114,10 +114,10 @@ g_socks5_proxy_init (GSocks5Proxy *proxy)
* +----+----------+----------+
*/
#define SOCKS5_NEGO_MSG_LEN 4
static gint
static size_t
set_nego_msg (guint8 *msg, gboolean has_auth)
{
gint len = 3;
size_t len = 3;
msg[0] = SOCKS5_VERSION;
msg[1] = 0x01; /* number of methods supported */
@ -200,15 +200,20 @@ parse_nego_reply (const guint8 *data,
}
#define SOCKS5_AUTH_MSG_LEN 515
static gint
static gboolean
set_auth_msg (guint8 *msg,
const gchar *username,
const gchar *password,
size_t *out_len,
GError **error)
{
gint len = 0;
gint ulen = 0; /* username length */
gint plen = 0; /* Password length */
size_t len = 0;
size_t ulen = 0; /* username length */
size_t plen = 0; /* Password length */
/* Clear output first */
if (out_len != NULL)
*out_len = 0;
if (username)
ulen = strlen (username);
@ -221,7 +226,7 @@ set_auth_msg (guint8 *msg,
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PROXY_FAILED,
_("Username or password is too long for SOCKSv5 "
"protocol."));
return -1;
return FALSE;
}
msg[len++] = SOCKS5_AUTH_VERSION;
@ -238,7 +243,10 @@ set_auth_msg (guint8 *msg,
len += plen;
return len;
if (out_len != NULL)
*out_len = len;
return TRUE;
}
@ -266,13 +274,18 @@ check_auth_status (const guint8 *data, GError **error)
* longer then 256 bytes.
*/
#define SOCKS5_CONN_MSG_LEN 262
static gint
static gboolean
set_connect_msg (guint8 *msg,
const gchar *hostname,
guint16 port,
size_t *out_len,
GError **error)
{
guint len = 0;
size_t len = 0;
/* Clear output first */
if (out_len != NULL)
*out_len = 0;
msg[len++] = SOCKS5_VERSION;
msg[len++] = SOCKS5_CMD_CONNECT;
@ -301,7 +314,7 @@ set_connect_msg (guint8 *msg,
g_set_error (error, G_IO_ERROR, G_IO_ERROR_PROXY_FAILED,
_("Hostname “%s” is too long for SOCKSv5 protocol"),
hostname);
return -1;
return FALSE;
}
msg[len++] = SOCKS5_ATYP_DOMAINNAME;
@ -316,7 +329,10 @@ set_connect_msg (guint8 *msg,
len += 2;
}
return len;
if (out_len != NULL)
*out_len = len;
return TRUE;
}
/*
@ -447,7 +463,7 @@ g_socks5_proxy_connect (GProxy *proxy,
/* Send SOCKS5 handshake */
{
guint8 msg[SOCKS5_NEGO_MSG_LEN];
gint len;
size_t len;
len = set_nego_msg (msg, has_auth);
@ -471,11 +487,9 @@ g_socks5_proxy_connect (GProxy *proxy,
if (must_auth)
{
guint8 msg[SOCKS5_AUTH_MSG_LEN];
gint len;
size_t len;
len = set_auth_msg (msg, username, password, error);
if (len < 0)
if (!set_auth_msg (msg, username, password, &len, error))
goto error;
if (!g_output_stream_write_all (out, msg, len, NULL,
@ -494,11 +508,9 @@ g_socks5_proxy_connect (GProxy *proxy,
/* Send SOCKS5 connection request */
{
guint8 msg[SOCKS5_CONN_MSG_LEN];
gint len;
size_t len;
len = set_connect_msg (msg, hostname, port, error);
if (len < 0)
if (!set_connect_msg (msg, hostname, port, &len, error))
goto error;
if (!g_output_stream_write_all (out, msg, len, NULL,
@ -561,8 +573,8 @@ typedef struct
gchar *username;
gchar *password;
guint8 *buffer;
gssize length;
gssize offset;
size_t length;
size_t offset;
} ConnectAsyncData;
static void nego_msg_write_cb (GObject *source,
@ -751,13 +763,13 @@ nego_reply_read_cb (GObject *source,
g_free (data->buffer);
data->buffer = g_malloc0 (SOCKS5_AUTH_MSG_LEN);
data->length = set_auth_msg (data->buffer,
data->username,
data->password,
&error);
data->offset = 0;
if (data->length < 0)
if (!set_auth_msg (data->buffer,
data->username,
data->password,
&data->length,
&error))
{
g_task_return_error (task, error);
g_object_unref (task);
@ -873,13 +885,13 @@ send_connect_msg (GTask *task)
g_free (data->buffer);
data->buffer = g_malloc0 (SOCKS5_CONN_MSG_LEN);
data->length = set_connect_msg (data->buffer,
data->hostname,
data->port,
&error);
data->offset = 0;
if (data->length < 0)
if (!set_connect_msg (data->buffer,
data->hostname,
data->port,
&data->length,
&error))
{
g_task_return_error (task, error);
g_object_unref (task);

View File

@ -472,15 +472,21 @@ g_unix_socket_address_new_with_type (const gchar *path,
{
GSocketAddress *address;
GByteArray *array;
size_t path_len_unsigned;
if (type == G_UNIX_SOCKET_ADDRESS_ANONYMOUS)
path_len = 0;
else if (path_len == -1)
path_len = strlen (path);
path_len_unsigned = 0;
else if (path_len < 0)
path_len_unsigned = strlen (path);
else
path_len_unsigned = (size_t) path_len;
array = g_byte_array_sized_new (path_len);
/* The code below cant handle anything longer. */
g_return_val_if_fail (path_len_unsigned <= G_MAXUINT, NULL);
g_byte_array_append (array, (guint8 *)path, path_len);
array = g_byte_array_sized_new (path_len_unsigned);
g_byte_array_append (array, (guint8 *)path, path_len_unsigned);
address = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
"path-as-array", array,

View File

@ -63,7 +63,7 @@ test_read_lines (GDataStreamNewlineType newline_type)
GError *error = NULL;
gpointer data;
char *lines;
int size;
size_t size;
int i;
#define TEST_STRING "some_text"
@ -99,7 +99,7 @@ test_read_lines (GDataStreamNewlineType newline_type)
/* compare data */
size = strlen (data);
g_assert_cmpint (size, <, MAX_LINES_BUFF);
g_assert_cmpuint (size, <, MAX_LINES_BUFF);
g_assert_cmpstr ((char*)data, ==, lines);
g_object_unref (base_stream);

View File

@ -1470,7 +1470,7 @@ test_run_in_thread_overflow (void)
GCancellable *cancellable;
GTask *task;
gchar buf[NUM_OVERFLOW_TASKS + 1];
gint i;
size_t i;
/* Queue way too many tasks and then sleep for a bit. The first 10
* tasks will be dispatched to threads and will then block on
@ -1516,13 +1516,13 @@ test_run_in_thread_overflow (void)
* plausibly get (and we hope that if gtask is actually broken then
* it will exceed those limits).
*/
g_assert_cmpint (i, >=, 10);
g_assert_cmpuint (i, >=, 10);
if (g_test_slow ())
g_assert_cmpint (i, <, 50);
g_assert_cmpuint (i, <, 50);
else
g_assert_cmpint (i, <, 20);
g_assert_cmpuint (i, <, 20);
g_assert_cmpint (i + strspn (buf + i, "X"), ==, NUM_OVERFLOW_TASKS);
g_assert_cmpuint (i + strspn (buf + i, "X"), ==, NUM_OVERFLOW_TASKS);
}
/* test_return_on_cancel */

View File

@ -160,8 +160,8 @@ g_win32_fs_monitor_callback (DWORD error,
if (monitor->isfile)
{
gint long_filename_length = wcslen (monitor->wfilename_long);
gint short_filename_length = wcslen (monitor->wfilename_short);
size_t long_filename_length = wcslen (monitor->wfilename_long);
size_t short_filename_length = wcslen (monitor->wfilename_short);
enum GWin32FileMonitorFileAlias alias_state;
/* If monitoring a file, check that the changed file

View File

@ -318,7 +318,7 @@ static const char *
match_prefix (const char *path,
const char *prefix)
{
int prefix_len;
size_t prefix_len;
prefix_len = strlen (prefix);
if (strncmp (path, prefix, prefix_len) != 0)

View File

@ -223,12 +223,14 @@ gi_base_info_type_register_static (const char *type_name,
{
GTypeInfo info;
g_assert (instance_size <= G_MAXUINT16);
info.class_size = sizeof (GIBaseInfoClass);
info.base_init = NULL;
info.base_finalize = NULL;
info.class_init = class_init;
info.class_finalize = NULL;
info.instance_size = instance_size;
info.instance_size = (guint16) instance_size;
info.n_preallocs = 0;
info.instance_init = NULL;
info.value_table = NULL;

View File

@ -651,7 +651,7 @@ gi_callable_info_invoke (GICallableInfo *info,
GITypeInfo *rinfo;
GITypeTag rtag;
GIArgInfo *ainfo;
size_t n_args, n_invoke_args, in_pos, out_pos, i;
unsigned int n_args, n_invoke_args, in_pos, out_pos, i;
void **args;
gboolean success = FALSE;
GError *local_error = NULL;

View File

@ -190,7 +190,7 @@ gi_field_info_get_field (GIFieldInfo *field_info,
void *mem,
GIArgument *value)
{
int offset;
size_t offset;
GITypeInfo *type_info;
gboolean result = FALSE;
@ -385,7 +385,7 @@ gi_field_info_set_field (GIFieldInfo *field_info,
void *mem,
const GIArgument *value)
{
int offset;
size_t offset;
GITypeInfo *type_info;
gboolean result = FALSE;

View File

@ -571,7 +571,7 @@ gi_ir_node_get_size (GIIrNode *node)
g_assert (size <= G_MAXUINT32);
return size;
return (guint32) size;
}
static void

View File

@ -1338,7 +1338,8 @@ gi_ir_writer_write (GIRepository *repository,
gboolean show_all)
{
FILE *ofile;
size_t i, j;
size_t i;
unsigned int j;
char **dependencies;
Xml *xml;

View File

@ -424,7 +424,8 @@ guchar *
g_base64_decode_inplace (gchar *text,
gsize *out_len)
{
gint input_length, state = 0;
gint state = 0;
size_t input_length;
guint save = 0;
g_return_val_if_fail (text != NULL, NULL);

View File

@ -2258,6 +2258,7 @@ win32_strftime_helper (const GDate *d,
gchar *convbuf;
glong convlen = 0;
gsize retval;
size_t format_len = strlen (format);
systemtime.wYear = tm->tm_year + 1900;
systemtime.wMonth = tm->tm_mon + 1;
@ -2269,7 +2270,8 @@ win32_strftime_helper (const GDate *d,
systemtime.wMilliseconds = 0;
lcid = GetThreadLocale ();
result = g_array_sized_new (FALSE, FALSE, sizeof (wchar_t), MAX (128, strlen (format) * 2));
result = g_array_sized_new (FALSE, FALSE, sizeof (wchar_t),
(format_len <= 64) ? (guint) format_len * 2 : 128);
p = format;
while (*p)

View File

@ -3268,7 +3268,7 @@ g_date_time_format_utf8 (GDateTime *datetime,
GString *outstr,
gboolean locale_is_utf8)
{
guint len;
size_t len;
guint colons;
gunichar c;
gboolean alt_digits = FALSE;

View File

@ -647,7 +647,7 @@ g_get_environ (void)
{
gunichar2 *strings;
gchar **result;
gint i, n;
size_t i, n;
strings = GetEnvironmentStringsW ();
for (n = 0, i = 0; strings[n]; i++)

View File

@ -373,7 +373,7 @@ g_file_test (const gchar *filename,
{
const gchar *lastdot = strrchr (filename, '.');
const gchar *pathext = NULL, *p;
int extlen;
size_t extlen;
if (lastdot == NULL)
break;
@ -401,7 +401,7 @@ g_file_test (const gchar *filename,
const gchar *q = strchr (p, ';');
if (q == NULL)
q = p + strlen (p);
if (extlen == q - p &&
if (extlen == (size_t) (q - p) &&
memcmp (lastdot, p, extlen) == 0)
{
g_free ((gchar *) pathext);

View File

@ -1420,9 +1420,9 @@ win32_is_pipe_tty (int fd)
gboolean result = FALSE;
HANDLE h_fd;
FILE_NAME_INFO *info = NULL;
gint info_size = sizeof (FILE_NAME_INFO) + sizeof (WCHAR) * MAX_PATH;
size_t info_size = sizeof (FILE_NAME_INFO) + sizeof (WCHAR) * MAX_PATH;
wchar_t *name = NULL;
gint length;
size_t length;
h_fd = (HANDLE) _get_osfhandle (fd);

View File

@ -1461,7 +1461,7 @@ parse_long_option (GOptionContext *context,
}
else
{
gint len = strlen (group->entries[j].long_name);
size_t len = strlen (group->entries[j].long_name);
if (strncmp (arg, group->entries[j].long_name, len) == 0 &&
(arg[len] == '=' || arg[len] == 0))

View File

@ -65,9 +65,9 @@ typedef enum
struct _GPatternSpec
{
GMatchType match_type;
guint pattern_length;
guint min_length;
guint max_length;
size_t pattern_length;
size_t min_length;
size_t max_length;
gchar *pattern;
};

View File

@ -930,7 +930,7 @@ g_ascii_formatd (gchar *buffer,
const char *decimal_point;
gsize decimal_point_len;
gchar *p;
int rest_len;
size_t rest_len;
gchar format_char;
g_return_val_if_fail (buffer != NULL, NULL);

View File

@ -134,7 +134,7 @@ g_string_new (const gchar *init)
string = g_string_sized_new (2);
else
{
gint len;
size_t len;
len = strlen (init);
string = g_string_sized_new (len + 2);

View File

@ -3035,7 +3035,7 @@ static gboolean
path_has_prefix (const char *path,
const char *prefix)
{
int prefix_len = strlen (prefix);
size_t prefix_len = strlen (prefix);
return (strncmp (path, prefix, prefix_len) == 0 &&
(path[prefix_len] == '\0' ||

View File

@ -187,11 +187,11 @@ lookup_item_id_for_locale (const gchar *locale)
{
gchar key[MAX_LOCALE_NAME + 1];
const gchar *language;
guint language_len;
size_t language_len;
const gchar *territory = NULL;
guint territory_len = 0;
size_t territory_len = 0;
const gchar *modifier = NULL;
guint modifier_len = 0;
size_t modifier_len = 0;
const gchar *next_char;
guint id;

View File

@ -805,7 +805,7 @@ output_special_case (gchar *out_buffer,
int which)
{
const gchar *p = special_case_table + offset;
gint len;
size_t len;
if (type != G_UNICODE_TITLECASE_LETTER)
p = g_utf8_next_char (p);

View File

@ -1250,7 +1250,7 @@ g_utf16_to_ucs4 (const gunichar2 *str,
const gunichar2 *in;
gchar *out;
gchar *result = NULL;
gint n_bytes;
size_t n_bytes;
gunichar high_surrogate;
g_return_val_if_fail (str != NULL, NULL);

View File

@ -196,7 +196,7 @@ g_find_program_in_path (const gchar *program)
strchr (last_dot, '\\') != NULL ||
strchr (last_dot, '/') != NULL)
{
const gint program_length = strlen (program);
const size_t program_length = strlen (program);
gchar *pathext = g_build_path (";",
".exe;.cmd;.bat;.com",
g_getenv ("PATHEXT"),

View File

@ -327,10 +327,10 @@ static gboolean
token_stream_peek_string (TokenStream *stream,
const gchar *token)
{
gint length = strlen (token);
size_t length = strlen (token);
return token_stream_prepare (stream) &&
stream->stream - stream->this == length &&
(size_t) (stream->stream - stream->this) == length &&
memcmp (stream->this, token, length) == 0;
}

View File

@ -133,7 +133,7 @@ array_new_zero_terminated (void)
garray = g_array_new (TRUE, FALSE, sizeof (gchar));
g_assert_cmpuint (garray->len, ==, 0);
g_array_append_vals (garray, "hello", strlen ("hello"));
g_array_append_vals (garray, "hello", (guint) strlen ("hello"));
g_assert_cmpuint (garray->len, ==, 5);
g_assert_cmpstr (garray->data, ==, "hello");

View File

@ -313,7 +313,7 @@ invalid_mutation (const gchar *type_string)
/* else, perform a random mutation at a random point */
{
gint length, n;
size_t length, n;
gchar *new;
gchar p;

View File

@ -37,9 +37,9 @@ typedef enum
struct _GPatternSpec
{
GMatchType match_type;
guint pattern_length;
guint min_length;
guint max_length;
size_t pattern_length;
size_t min_length;
size_t max_length;
gchar *pattern;
};
@ -50,7 +50,7 @@ struct _CompileTest
const gchar *src;
GMatchType match_type;
gchar *pattern;
guint min;
size_t min;
};
static CompileTest compile_tests[] = {
@ -80,8 +80,8 @@ test_compilation (gconstpointer d)
g_assert_cmpint (spec->match_type, ==, test->match_type);
g_assert_cmpstr (spec->pattern, ==, test->pattern);
g_assert_cmpint (spec->pattern_length, ==, strlen (spec->pattern));
g_assert_cmpint (spec->min_length, ==, test->min);
g_assert_cmpuint (spec->pattern_length, ==, strlen (spec->pattern));
g_assert_cmpuint (spec->min_length, ==, test->min);
g_pattern_spec_free (spec);
}
@ -97,8 +97,8 @@ test_copy (gconstpointer d)
g_assert_cmpint (p2->match_type, ==, test->match_type);
g_assert_cmpstr (p2->pattern, ==, test->pattern);
g_assert_cmpint (p2->pattern_length, ==, strlen (p1->pattern));
g_assert_cmpint (p2->min_length, ==, test->min);
g_assert_cmpuint (p2->pattern_length, ==, strlen (p1->pattern));
g_assert_cmpuint (p2->min_length, ==, test->min);
g_pattern_spec_free (p1);
g_pattern_spec_free (p2);
@ -186,7 +186,8 @@ test_match (gconstpointer d)
r = g_utf8_strreverse (test->string, -1);
g_assert_cmpint (g_pattern_spec_match (p, strlen (test->string), test->string, r), ==, test->match);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_assert_cmpint (g_pattern_match (p, strlen (test->string), test->string, r), ==, test->match);
g_assert_cmpuint (strlen (test->string), <=, G_MAXUINT);
g_assert_cmpint (g_pattern_match (p, (guint) strlen (test->string), test->string, r), ==, test->match);
G_GNUC_END_IGNORE_DEPRECATIONS
g_free (r);

View File

@ -111,7 +111,7 @@ test_scanner_tokens (ScannerFixture *fix,
gconstpointer test_data)
{
gchar buf[] = "(\t\n\r\\){}";
const gint buflen = strlen (buf);
const size_t buflen = strlen (buf);
gchar tokbuf[] = "(\\){}";
const gsize tokbuflen = strlen (tokbuf);
gsize i;

View File

@ -36,7 +36,8 @@ WinMain (struct HINSTANCE__ *hInstance,
{
int infd = atoi (__argv[2]);
int outfd = atoi (__argv[3]);
int k, n;
SSIZE_T k;
size_t n;
char buf[100] = {0};
if (infd < 0 || outfd < 0)
@ -55,22 +56,28 @@ WinMain (struct HINSTANCE__ *hInstance,
exit (1);
}
if ((k = read (infd, &n, sizeof (n))) != sizeof (n))
k = read (infd, &n, sizeof (n));
if (k < 0 || (size_t) k != sizeof (n))
{
fprintf (stderr, "spawn-test-win32-gui: Got only %d bytes, wanted %d\n",
k, (int)sizeof (n));
int errsv = errno;
if (k < 0)
fprintf (stderr, "spawn-test-win32-gui: Read error: %s\n", strerror (errsv));
else
fprintf (stderr, "spawn-test-win32-gui: Got only %zu bytes, wanted %zu\n",
(size_t) k, sizeof (n));
exit (1);
}
fprintf (stderr, "spawn-test-win32-gui: Parent says %d bytes to read\n", n);
fprintf (stderr, "spawn-test-win32-gui: Parent says %zu bytes to read\n", n);
if ((k = read (infd, buf, n)) != n)
k = read (infd, buf, n);
if (k < 0 || (size_t) k != n)
{
int errsv = errno;
if (k == -1)
if (k < 0)
fprintf (stderr, "spawn-test-win32-gui: Read error: %s\n", strerror (errsv));
else
fprintf (stderr, "spawn-test-win32-gui: Got only %d bytes\n", k);
fprintf (stderr, "spawn-test-win32-gui: Got only %zu bytes\n", (size_t) k);
exit (1);
}

View File

@ -198,7 +198,7 @@ test_spawn_basics (void)
gchar *output = NULL;
gchar *erroutput = NULL;
#ifdef G_OS_WIN32
int n;
size_t n;
char buf[100];
int pipedown[2], pipeup[2];
gchar **argv = NULL;

View File

@ -455,7 +455,7 @@ test_tree_insert (void)
{
GTree *tree;
gchar *p;
gint i;
size_t i;
gchar *scrambled;
tree = g_tree_new (my_compare);
@ -468,8 +468,8 @@ test_tree_insert (void)
g_tree_unref (tree);
tree = g_tree_new (my_compare);
for (i = strlen (chars) - 1; i >= 0; i--)
g_tree_insert (tree, &chars[i], &chars[i]);
for (i = strlen (chars); i > 0; i--)
g_tree_insert (tree, &chars[i - 1], &chars[i - 1]);
p = chars;
g_tree_foreach (tree, check_order, &p);

View File

@ -205,7 +205,7 @@ static gchar*
_g_module_build_path (const gchar *directory,
const gchar *module_name)
{
gint k;
size_t k;
k = strlen (module_name);

View File

@ -47,7 +47,7 @@ show_nodes (GType type,
const gchar *indent)
{
GType *children;
guint i;
size_t i;
if (!type)
return;

View File

@ -1073,7 +1073,7 @@ type_data_make_W (TypeNode *node,
{
TypeData *data;
GTypeValueTable *vtable = NULL;
guint vtable_size = 0;
size_t vtable_size = 0;
g_assert (node->data == NULL && info != NULL);