@@ -928,7 +928,8 @@ static void vsc73xx_get_strings(struct dsa_switch *ds, int port, u32 stringset,
928
928
const struct vsc73xx_counter * cnt ;
929
929
struct vsc73xx * vsc = ds -> priv ;
930
930
u8 indices [6 ];
931
- int i , j ;
931
+ u8 * buf = data ;
932
+ int i ;
932
933
u32 val ;
933
934
int ret ;
934
935
@@ -948,10 +949,7 @@ static void vsc73xx_get_strings(struct dsa_switch *ds, int port, u32 stringset,
948
949
indices [5 ] = ((val >> 26 ) & 0x1f ); /* TX counter 2 */
949
950
950
951
/* The first counters is the RX octets */
951
- j = 0 ;
952
- strncpy (data + j * ETH_GSTRING_LEN ,
953
- "RxEtherStatsOctets" , ETH_GSTRING_LEN );
954
- j ++ ;
952
+ ethtool_sprintf (& buf , "RxEtherStatsOctets" );
955
953
956
954
/* Each port supports recording 3 RX counters and 3 TX counters,
957
955
* figure out what counters we use in this set-up and return the
@@ -961,23 +959,16 @@ static void vsc73xx_get_strings(struct dsa_switch *ds, int port, u32 stringset,
961
959
*/
962
960
for (i = 0 ; i < 3 ; i ++ ) {
963
961
cnt = vsc73xx_find_counter (vsc , indices [i ], false);
964
- if (cnt )
965
- strncpy (data + j * ETH_GSTRING_LEN ,
966
- cnt -> name , ETH_GSTRING_LEN );
967
- j ++ ;
962
+ ethtool_sprintf (& buf , "%s" , cnt ? cnt -> name : "" );
968
963
}
969
964
970
965
/* TX stats begins with the number of TX octets */
971
- strncpy (data + j * ETH_GSTRING_LEN ,
972
- "TxEtherStatsOctets" , ETH_GSTRING_LEN );
973
- j ++ ;
966
+ ethtool_sprintf (& buf , "TxEtherStatsOctets" );
974
967
975
968
for (i = 3 ; i < 6 ; i ++ ) {
976
969
cnt = vsc73xx_find_counter (vsc , indices [i ], true);
977
- if (cnt )
978
- strncpy (data + j * ETH_GSTRING_LEN ,
979
- cnt -> name , ETH_GSTRING_LEN );
980
- j ++ ;
970
+ ethtool_sprintf (& buf , "%s" , cnt ? cnt -> name : "" );
971
+
981
972
}
982
973
}
983
974
0 commit comments