summaryrefslogtreecommitdiff
path: root/src/sm_genid.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-11-19 10:01:50 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-09 17:35:30 -0800
commit9f350d75a4553d8e2bc365f8de4110bb79ec7b32 (patch)
tree5c23e3bd0e2bab0080aaccae7e716619e913d8eb /src/sm_genid.c
parent079de6fd4bd0423e20e472d7342f919eebce0517 (diff)
Move and rename temp[4] definition to reduce confusion with temp[256]
Both variables were locals in different scope levels of the same function, leading to both confusing code and gcc -Wshadow warnings: sm_genid.c: In function 'SmsGenerateClientID': sm_genid.c:160:10: warning: declaration of 'temp' shadows a previous local Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: James Cloos <cloos@jhcloos.com>
Diffstat (limited to 'src/sm_genid.c')
-rw-r--r--src/sm_genid.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/sm_genid.c b/src/sm_genid.c
index a8161ff..700bbf2 100644
--- a/src/sm_genid.c
+++ b/src/sm_genid.c
@@ -157,7 +157,7 @@ SmsGenerateClientID(SmsConn smsConn)
{
char* inet_addr;
- char temp[4], *ptr1, *ptr2;
+ char *ptr1;
unsigned char decimal[4];
int i, len;
struct in_addr *haddr = NULL;
@@ -204,7 +204,9 @@ SmsGenerateClientID(SmsConn smsConn)
inet_addr = inet_ntoa (*haddr);
for (i = 0, ptr1 = inet_addr; i < 3; i++)
{
- ptr2 = strchr (ptr1, '.');
+ char temp4[4];
+ char *ptr2 = strchr (ptr1, '.');
+
len = ptr2 - ptr1;
if (!ptr2 || len > 3) {
# if defined(IPv6) && defined(AF_INET6)
@@ -212,9 +214,9 @@ SmsGenerateClientID(SmsConn smsConn)
# endif
return (NULL);
}
- strncpy (temp, ptr1, len);
- temp[len] = '\0';
- decimal[i] = atoi (temp);
+ strncpy (temp4, ptr1, len);
+ temp4[len] = '\0';
+ decimal[i] = atoi (temp4);
ptr1 = ptr2 + 1;
}