Skip to content

Commit

Permalink
Fixed eglib compiler warnings about g_string_truncate() and g_iconv()
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Aug 13, 2013
1 parent 94f12d8 commit 82219ac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 16 additions & 2 deletions eglib/src/giconv.c
Expand Up @@ -180,8 +180,22 @@ g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft,
int rc = 0;

#ifdef HAVE_ICONV
if (cd->cd != (iconv_t) -1)
return iconv (cd->cd, inbytes, inbytesleft, outbytes, outbytesleft);
if (cd->cd != (iconv_t) -1) {
/* Note: gsize may have a different size than size_t, so we need to
remap inbytesleft and outbytesleft to size_t's. */
size_t *outleftptr;

if (outbytesleft) {
outleft = *outbytesleft;
outleftptr = &outleft;
} else {
outleftptr = NULL;
}

inleft = inbytesleft ? *inbytesleft : 0;

return iconv (cd->cd, inbytes, &inleft, outbytes, outleftptr);
}
#endif

if (outbytes == NULL || outbytesleft == NULL) {
Expand Down
3 changes: 1 addition & 2 deletions eglib/src/gstring.c
Expand Up @@ -235,9 +235,8 @@ g_string_truncate (GString *string, gsize len)
g_return_val_if_fail (string != NULL, string);

/* Silent return */
if (len < 0 || len >= string->len) {
if (len >= string->len)
return string;
}

string->len = len;
string->str[len] = 0;
Expand Down

0 comments on commit 82219ac

Please sign in to comment.