diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-05-30 23:04:36 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-05-31 05:35:34 +0200 |
commit | 6f3a354105e1b06e398d8862e05c08c8e0223383 (patch) | |
tree | 6509352cc84796bc7c68129de53e3567626d5bf3 | |
parent | routingtable: Remove unnecessary check in node_placement() (diff) | |
download | wireguard-monolithic-historical-6f3a354105e1b06e398d8862e05c08c8e0223383.tar.xz wireguard-monolithic-historical-6f3a354105e1b06e398d8862e05c08c8e0223383.zip |
config: it's faster to memcpy than strncpy
IFNAMSIZ is 16, so this is two instructions on 64-bit.
-rw-r--r-- | src/config.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/config.c b/src/config.c index f3357b5..907c6b3 100644 --- a/src/config.c +++ b/src/config.c @@ -317,8 +317,7 @@ int config_get_device(struct wireguard_device *wg, void __user *user_device) out_device.version_magic = WG_API_VERSION_MAGIC; out_device.port = wg->incoming_port; out_device.fwmark = wg->fwmark; - strncpy(out_device.interface, dev->name, IFNAMSIZ - 1); - out_device.interface[IFNAMSIZ - 1] = 0; + memcpy(out_device.interface, dev->name, IFNAMSIZ); down_read(&wg->static_identity.lock); if (wg->static_identity.has_identity) { |