- irc.c:userinfo_create(): use pointer arithmetic instead of array subscripting
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Sun, 14 Jun 2015 19:21:37 +0000 (19:21 +0000)
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Sun, 14 Jun 2015 19:21:37 +0000 (19:21 +0000)
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@6150 82007160-df01-0410-b94d-b575c5fd34c7

src/irc.c

index 702e859a503f4735954a67c7aeb584772d5abf01..4c5ff8a72fbcd0aaac467fb9806a20395e9f3765 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -590,27 +590,27 @@ static struct UserInfo *
 userinfo_create(const char *source)
 {
   struct UserInfo *ret;
-  char *nick = NULL;
+  char tmp[MSGLENMAX];
+  char *nick = tmp;
   char *username = NULL;
   char *hostname = NULL;
-  char tmp[MSGLENMAX];
-  size_t len;
 
-  len = strlcpy(tmp, source, sizeof(tmp));
-  nick = tmp;
+  strlcpy(tmp, source, sizeof(tmp));
 
-  for (size_t i = 0; i < len; ++i)
+  for (char *p = tmp; *p; ++p)
   {
-    if (tmp[i] == '!')
+    if (*p == '!')
     {
-      tmp[i] = '\0';
-      username = tmp + i + 1;
+      *p = '\0';
+      username = p + 1;
+      continue;
     }
 
-    if (tmp[i] == '@')
+    if (*p == '@')
     {
-      tmp[i] = '\0';
-      hostname = tmp + i + 1;
+      *p = '\0';
+      hostname = p + 1;
+      continue;
     }
   }