@@ -904,30 +904,32 @@ static GHashTable *
904904build_port_aliases (const char * hostmap , GList * * targets )
905905{
906906 char * name = NULL ;
907- int last = 0 , lpc = 0 , max = 0 , added = 0 ;
907+ int last = 0 ;
908+ int added = 0 ;
909+ size_t len = 0 ;
908910 GHashTable * aliases = pcmk__strikey_table (free , free );
909911
910912 if (hostmap == NULL ) {
911913 return aliases ;
912914 }
913915
914- max = strlen (hostmap );
915- for (; lpc <= max ; lpc ++ ) {
916- switch (hostmap [lpc ]) {
916+ len = strlen (hostmap );
917+ for (int i = 0 ; i <= len ; i ++ ) {
918+ switch (hostmap [i ]) {
917919 /* Skip escaped chars */
918920 case '\\' :
919- lpc ++ ;
921+ i ++ ;
920922 break ;
921923
922924 /* Assignment chars */
923925 case '=' :
924926 case ':' :
925- if (lpc > last ) {
927+ if (i > last ) {
926928 free (name );
927- name = pcmk__assert_alloc (1 , 1 + lpc - last );
928- memcpy (name , hostmap + last , lpc - last );
929+ name = pcmk__assert_alloc (1 , 1 + i - last );
930+ memcpy (name , hostmap + last , i - last );
929931 }
930- last = lpc + 1 ;
932+ last = i + 1 ;
931933 break ;
932934
933935 /* Delimeter chars */
@@ -940,8 +942,8 @@ build_port_aliases(const char *hostmap, GList ** targets)
940942 char * value = NULL ;
941943 int k = 0 ;
942944
943- value = pcmk__assert_alloc (1 , 1 + lpc - last );
944- memcpy (value , hostmap + last , lpc - last );
945+ value = pcmk__assert_alloc (1 , 1 + i - last );
946+ memcpy (value , hostmap + last , i - last );
945947
946948 for (int i = 0 ; value [i ] != '\0' ; i ++ ) {
947949 if (value [i ] != '\\' ) {
@@ -959,15 +961,16 @@ build_port_aliases(const char *hostmap, GList ** targets)
959961 name = NULL ;
960962 added ++ ;
961963
962- } else if (lpc > last ) {
963- crm_debug ("Parse error at offset %d near '%s'" , lpc - last , hostmap + last );
964+ } else if (i > last ) {
965+ crm_debug ("Parse error at offset %d near '%s'" , i - last ,
966+ hostmap + last );
964967 }
965968
966- last = lpc + 1 ;
969+ last = i + 1 ;
967970 break ;
968971 }
969972
970- if (hostmap [lpc ] == 0 ) {
973+ if (hostmap [i ] == 0 ) {
971974 break ;
972975 }
973976 }
0 commit comments