Minor documentation and formatting fixes #799

Closed
opened 2026-08-28 08:08:52 -05:00 by headscott · 1 comment
headscott commented 2026-08-28 08:08:52 -05:00 (Migrated from github.com)

I noticed a few small typos, documentation inconsistencies, and formatting issues.
These are all minor cleanup items, but fixing them would improve consistency and readability:

  • ltc_pkcs_1_pss_encode_mgf1.c:72: remove the unnecessary blank line
  • hmac_init.c:67: remove extra spaces
  • hash_memory.c: hash_descriptor[hash].hashsize is accessed multiple times. It could be stored in a local variable (like in hmac_done.c) after validating the hash, and then reused throughout the function:
unsigned long hashsize;

/* ... */

if ((err = hash_is_valid(hash)) != CRYPT_OK) {
    return err;
}

hashsize = hash_descriptor[hash].hashsize;

  • der_decode_choice.c:111+112: align the calculation lines
  • der_decode_integer.c:75: remove the unnecessary blank line
  • der_decode_short_integer.c:62: remove the unnecessary blank line
  • der_decode_utctime.c:74-81: align the comment
  • der_decode_generalizedtime.c:91-98: align the comment
  • s_der_decode_sequence_flexi.c: The XMALLOC, XCALLOC and XREALLOC calls use a code style that differs from the rest of the codebase. I would prefer to write them as separate assignment and NULL-check statements, for example:
             l->data = XMALLOC(len);
             if(l->data == NULL) {
                err = CRYPT_MEM;
                goto error;
             }

instead of:

             if ((l->data = XMALLOC(len)) == NULL) {
                err = CRYPT_MEM;
                goto error;
             }
I noticed a few small typos, documentation inconsistencies, and formatting issues. These are all minor cleanup items, but fixing them would improve consistency and readability: * `ltc_pkcs_1_pss_encode_mgf1.c:72`: remove the unnecessary blank line * `hmac_init.c:67`: remove extra spaces * `hash_memory.c`: `hash_descriptor[hash].hashsize` is accessed multiple times. It could be stored in a local variable (like in `hmac_done.c`) after validating the hash, and then reused throughout the function: ```c unsigned long hashsize; /* ... */ if ((err = hash_is_valid(hash)) != CRYPT_OK) { return err; } hashsize = hash_descriptor[hash].hashsize; ``` * `der_decode_choice.c:111+112`: align the calculation lines * `der_decode_integer.c:75`: remove the unnecessary blank line * `der_decode_short_integer.c:62`: remove the unnecessary blank line * `der_decode_utctime.c:74-81`: align the comment * `der_decode_generalizedtime.c:91-98`: align the comment * `s_der_decode_sequence_flexi.c`: The `XMALLOC`, `XCALLOC` and `XREALLOC` calls use a code style that differs from the rest of the codebase. I would prefer to write them as separate assignment and NULL-check statements, for example: ```c l->data = XMALLOC(len); if(l->data == NULL) { err = CRYPT_MEM; goto error; } ``` instead of: ```c if ((l->data = XMALLOC(len)) == NULL) { err = CRYPT_MEM; goto error; } ```
karel-m commented 2026-08-31 04:43:38 -05:00 (Migrated from github.com)

I am not sure about changing "separate assignment + NULL-check" the rest is fixed in #800

I am not sure about changing "separate assignment + NULL-check" the rest is fixed in #800
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libtom/libtomcrypt#799
No description provided.