diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-02-06 20:41:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-02-07 23:44:37 -0500 |
commit | 241448c2b84ff02a46ce88199e05fdeb55bad449 (patch) | |
tree | 41ae60dff8ed4f72657271892dd618754cc3e78a /net/sctp | |
parent | 85bd1798b24a13462d7b064961e7a9da3bb12db1 (diff) |
net: sctp: sctp_auth_make_key_vector: remove duplicate ntohs calls
Instead of calling 3 times ntohs(random->param_hdr.length), 2 times
ntohs(hmacs->param_hdr.length), and 3 times ntohs(chunks->param_hdr.length)
within the same function, we only call each once and store it in a
variable.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/auth.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 159b9bc5d633..94a12de58691 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
@@ -200,10 +200,14 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector( | |||
200 | struct sctp_auth_bytes *new; | 200 | struct sctp_auth_bytes *new; |
201 | __u32 len; | 201 | __u32 len; |
202 | __u32 offset = 0; | 202 | __u32 offset = 0; |
203 | __u16 random_len, hmacs_len, chunks_len = 0; | ||
203 | 204 | ||
204 | len = ntohs(random->param_hdr.length) + ntohs(hmacs->param_hdr.length); | 205 | random_len = ntohs(random->param_hdr.length); |
205 | if (chunks) | 206 | hmacs_len = ntohs(hmacs->param_hdr.length); |
206 | len += ntohs(chunks->param_hdr.length); | 207 | if (chunks) |
208 | chunks_len = ntohs(chunks->param_hdr.length); | ||
209 | |||
210 | len = random_len + hmacs_len + chunks_len; | ||
207 | 211 | ||
208 | new = kmalloc(sizeof(struct sctp_auth_bytes) + len, gfp); | 212 | new = kmalloc(sizeof(struct sctp_auth_bytes) + len, gfp); |
209 | if (!new) | 213 | if (!new) |
@@ -211,16 +215,15 @@ static struct sctp_auth_bytes *sctp_auth_make_key_vector( | |||
211 | 215 | ||
212 | new->len = len; | 216 | new->len = len; |
213 | 217 | ||
214 | memcpy(new->data, random, ntohs(random->param_hdr.length)); | 218 | memcpy(new->data, random, random_len); |
215 | offset += ntohs(random->param_hdr.length); | 219 | offset += random_len; |
216 | 220 | ||
217 | if (chunks) { | 221 | if (chunks) { |
218 | memcpy(new->data + offset, chunks, | 222 | memcpy(new->data + offset, chunks, chunks_len); |
219 | ntohs(chunks->param_hdr.length)); | 223 | offset += chunks_len; |
220 | offset += ntohs(chunks->param_hdr.length); | ||
221 | } | 224 | } |
222 | 225 | ||
223 | memcpy(new->data + offset, hmacs, ntohs(hmacs->param_hdr.length)); | 226 | memcpy(new->data + offset, hmacs, hmacs_len); |
224 | 227 | ||
225 | return new; | 228 | return new; |
226 | } | 229 | } |