Messages in this thread | | | Date | Tue, 30 May 2023 13:50:02 -0700 | Subject | Re: [PATCH v7 10/12] crypto: x86/aesni - Use the proper data type in struct aesni_xts_ctx | From | "Chang S. Bae" <> |
| |
On 5/25/2023 11:54 PM, Eric Biggers wrote: > On Wed, May 24, 2023 at 09:57:15AM -0700, Chang S. Bae wrote: >> +static inline unsigned long aes_align_addr(unsigned long addr) >> +{ >> + return (crypto_tfm_ctx_alignment() >= AESNI_ALIGN) ? >> + ALIGN(addr, 1) : ALIGN(addr, AESNI_ALIGN); >> +} > > Wouldn't it be simpler to make this take and return 'void *'? Then the callers > wouldn't need to cast to/from 'unsigned long'. > > Also, aligning to a 1-byte boundary is a no-op. > > So, please consider the following: > > static inline void *aes_align_addr(void *addr) > { > if (crypto_tfm_ctx_alignment() >= AES_ALIGN) > return addr; > return PTR_ALIGN(addr, AES_ALIGN); > } > > Also, aesni_rfc4106_gcm_ctx_get() and generic_gcmaes_ctx_get() should call this > too, rather than duplicating similar code.
Indeed, your suggestion can improve the overall code there.
Thanks! Chang
| |