mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-14 10:15:13 +00:00
l2tp: zero out stats in pppol2tp_copy_stats()
Integrate memset(0) in pppol2tp_copy_stats() to avoid calling it manually every time. While there, constify 'stats'. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b0e29063dc
commit
7390ed8a40
1 changed files with 3 additions and 4 deletions
|
|
@ -1026,8 +1026,10 @@ end:
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void pppol2tp_copy_stats(struct pppol2tp_ioc_stats *dest,
|
static void pppol2tp_copy_stats(struct pppol2tp_ioc_stats *dest,
|
||||||
struct l2tp_stats *stats)
|
const struct l2tp_stats *stats)
|
||||||
{
|
{
|
||||||
|
memset(dest, 0, sizeof(*dest));
|
||||||
|
|
||||||
dest->tx_packets = atomic_long_read(&stats->tx_packets);
|
dest->tx_packets = atomic_long_read(&stats->tx_packets);
|
||||||
dest->tx_bytes = atomic_long_read(&stats->tx_bytes);
|
dest->tx_bytes = atomic_long_read(&stats->tx_bytes);
|
||||||
dest->tx_errors = atomic_long_read(&stats->tx_errors);
|
dest->tx_errors = atomic_long_read(&stats->tx_errors);
|
||||||
|
|
@ -1044,7 +1046,6 @@ static int pppol2tp_tunnel_copy_stats(struct pppol2tp_ioc_stats *stats,
|
||||||
struct l2tp_session *session;
|
struct l2tp_session *session;
|
||||||
|
|
||||||
if (!stats->session_id) {
|
if (!stats->session_id) {
|
||||||
memset(stats, 0, sizeof(*stats));
|
|
||||||
pppol2tp_copy_stats(stats, &tunnel->stats);
|
pppol2tp_copy_stats(stats, &tunnel->stats);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1061,7 +1062,6 @@ static int pppol2tp_tunnel_copy_stats(struct pppol2tp_ioc_stats *stats,
|
||||||
return -EBADR;
|
return -EBADR;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(stats, 0, sizeof(*stats));
|
|
||||||
pppol2tp_copy_stats(stats, &session->stats);
|
pppol2tp_copy_stats(stats, &session->stats);
|
||||||
l2tp_session_dec_refcount(session);
|
l2tp_session_dec_refcount(session);
|
||||||
|
|
||||||
|
|
@ -1126,7 +1126,6 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd,
|
||||||
|
|
||||||
stats.session_id = session_id;
|
stats.session_id = session_id;
|
||||||
} else {
|
} else {
|
||||||
memset(&stats, 0, sizeof(stats));
|
|
||||||
pppol2tp_copy_stats(&stats, &session->stats);
|
pppol2tp_copy_stats(&stats, &session->stats);
|
||||||
stats.session_id = session->session_id;
|
stats.session_id = session->session_id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue