[misc] use less C99 features
parent
061b2a4262
commit
b783bd5aaa
|
@ -130,7 +130,10 @@ INLINE void li_path_append_slash(GString *path) {
|
|||
|
||||
/** warning: This "GString" does not make sure that there is a terminating '\0', and you shouldn't modify the GString */
|
||||
INLINE GString li_const_gstring(const gchar *str, gsize len) {
|
||||
GString gs = { (gchar*) str, len, 0 };
|
||||
GString gs;
|
||||
gs.str = (gchar*) str;
|
||||
gs.len = len;
|
||||
gs.allocated_len = 0;
|
||||
return gs;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,9 @@ liModules *li_modules_new(gpointer main, const gchar *module_dir, gboolean modul
|
|||
liModule *li_module_lookup(liModules *mods, const gchar *name) {
|
||||
liModule *mod;
|
||||
GArray *a = mods->mods;
|
||||
guint i;
|
||||
|
||||
for (guint i = 0; i < a->len; i++) {
|
||||
for (i = 0; i < a->len; i++) {
|
||||
mod = g_array_index(a, liModule*, i);
|
||||
if (mod != NULL && g_str_equal(mod->name->str, name))
|
||||
return mod;
|
||||
|
@ -31,8 +32,9 @@ void li_modules_free(liModules* mods) {
|
|||
/* unload all modules */
|
||||
GArray *a = mods->mods;
|
||||
liModule *mod;
|
||||
guint i;
|
||||
|
||||
for (guint i = 0; i < a->len; i++) {
|
||||
for (i = 0; i < a->len; i++) {
|
||||
mod = g_array_index(a, liModule*, i);
|
||||
if (!mod)
|
||||
continue;
|
||||
|
|
|
@ -498,6 +498,7 @@ GString *li_sockaddr_to_string(liSocketAddress addr, GString *dest, gboolean sho
|
|||
guint8 tmplen;
|
||||
guint8 oct;
|
||||
liSockAddr *saddr = addr.addr;
|
||||
guint i;
|
||||
|
||||
if (!saddr) {
|
||||
li_string_assign_len(dest, CONST_STR_LEN("<null>"));
|
||||
|
@ -514,7 +515,7 @@ GString *li_sockaddr_to_string(liSocketAddress addr, GString *dest, gboolean sho
|
|||
|
||||
p = dest->str;
|
||||
|
||||
for (guint i = 0; i < 4; i++) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
oct = ((guint8*)&saddr->ipv4.sin_addr.s_addr)[i];
|
||||
for (tmplen = 1, tmp = oct; tmp > 9; tmp /= 10)
|
||||
tmplen++;
|
||||
|
@ -688,7 +689,8 @@ gboolean li_ipv4_in_ipv6_net(guint32 target, const guint8 *match, guint network)
|
|||
|
||||
/* unused */
|
||||
void li_gstring_replace_char_with_str_len(GString *gstr, gchar c, gchar *str, guint len) {
|
||||
for (guint i = 0; i < gstr->len; i++) {
|
||||
guint i;
|
||||
for (i = 0; i < gstr->len; i++) {
|
||||
if (gstr->str[i] == c) {
|
||||
/* char found, replace */
|
||||
gstr->str[i] = str[0];
|
||||
|
|
Loading…
Reference in New Issue