Reformat calculation of padding size in stack set-up to increase clarity

This commit is contained in:
Themis Demetriades
2024-11-04 12:54:18 +00:00
parent 6c6ce77824
commit 2a890d5bd2

View File

@@ -2,6 +2,7 @@
#include <debug.h> #include <debug.h>
#include <inttypes.h> #include <inttypes.h>
#include <round.h> #include <round.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -116,7 +117,7 @@ start_process (void *file_name_)
/* Calculate the remaining number of bytes that need to be written /* Calculate the remaining number of bytes that need to be written
to the user process stack in order to check for possible overflow. */ to the user process stack in order to check for possible overflow. */
size_t align_size = (unsigned int) if_.esp % 4; size_t align_size = ((unsigned int) if_.esp % 4) * sizeof (uint8_t);
size_t argv_data_size = (arg_count + 1) * sizeof (char *); size_t argv_data_size = (arg_count + 1) * sizeof (char *);
size_t argv_size = sizeof (char **); size_t argv_size = sizeof (char **);
size_t argc_size = sizeof (int); size_t argc_size = sizeof (int);
@@ -133,7 +134,7 @@ start_process (void *file_name_)
/* Align stack pointer to word size before pushing argv elements for /* Align stack pointer to word size before pushing argv elements for
performance. */ performance. */
if_.esp -= align_size * sizeof (uint8_t); if_.esp -= align_size;
/* Push a null pointer sentinel inside argv. */ /* Push a null pointer sentinel inside argv. */
if_.esp -= sizeof (char *); if_.esp -= sizeof (char *);