X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgt.c;h=8bb3f7d24008445abef75ba74bc2a4790798f88e;hb=3a2efc3143d89d036794f2d8274794482cb2c961;hp=391c361098c57103b8cf239b344d17bdef5b657e;hpb=9c6132dd0bfaca8edae84906ad70a6205b5ba42f;p=src%2Fapp-framework-main.git diff --git a/src/wgt.c b/src/wgt.c index 391c361..8bb3f7d 100644 --- a/src/wgt.c +++ b/src/wgt.c @@ -1,5 +1,5 @@ /* - Copyright 2015 IoT.bzh + Copyright (C) 2015-2020 IoT.bzh author: José Bollo @@ -34,7 +34,7 @@ struct wgt { int refcount; int rootfd; - int nrlocales; + unsigned int nrlocales; char **locales; }; @@ -262,16 +262,16 @@ int wgt_open_read(struct wgt *wgt, const char *filename) * Adds if needed the locale 'locstr' of 'length' * to the list of locales. */ -static int locadd(struct wgt *wgt, const char *locstr, int length) +static int locadd(struct wgt *wgt, const char *locstr, size_t length) { - int i; + unsigned int i; char *item, **ptr; item = strndup(locstr, length); if (item != NULL) { /* normalize in lower case */ for (i = 0 ; item[i] ; i++) - item[i] = tolower(item[i]); + item[i] = (char)tolower(item[i]); /* search it (no duplication) */ for (i = 0 ; i < wgt->nrlocales ; i++) @@ -323,7 +323,7 @@ int wgt_locales_add(struct wgt *wgt, const char *locstr) next = stop + !!*stop; /* iterate variant of languages in reverse order */ while (locstr != stop) { - if (locadd(wgt, locstr, stop - locstr)) + if (locadd(wgt, locstr, (size_t)(stop - locstr))) return -1; do { stop--; } while(stop > locstr && *stop != '-'); } @@ -338,9 +338,9 @@ int wgt_locales_add(struct wgt *wgt, const char *locstr) * The lower result means the higher priority of the language. * The returned value of 0 is the top first priority. */ -int wgt_locales_score(struct wgt *wgt, const char *lang) +unsigned int wgt_locales_score(struct wgt *wgt, const char *lang) { - int i; + unsigned int i; assert(wgt); if (lang) @@ -348,7 +348,7 @@ int wgt_locales_score(struct wgt *wgt, const char *lang) if (!strcasecmp(lang, wgt->locales[i])) return i; - return INT_MAX; + return UINT_MAX; } /* @@ -361,7 +361,7 @@ int wgt_locales_score(struct wgt *wgt, const char *lang) */ static const char *localize(struct wgt *wgt, const char *filename, char path[PATH_MAX]) { - int i; + unsigned int i; /* get the normalized name */ filename = normalsubpath(filename);