p = buffer = xmalloc(sz);
- for (UINTN i = 0; i < config->entry_count; i++) {
- UINTN l;
-
- l = strsize16(config->entries[i]->id);
- memcpy(p, config->entries[i]->id, l);
-
- p += l;
- }
+ for (UINTN i = 0; i < config->entry_count; i++)
+ p = mempcpy(p, config->entries[i]->id, strsize16(config->entries[i]->id));
assert(p == buffer + sz);
*cpio_buffer = a;
a = (char *) *cpio_buffer + *cpio_buffer_size;
- memcpy(a, "070701", 6); /* magic ID */
- a += 6;
+ a = mempcpy(a, "070701", 6); /* magic ID */
a = write_cpio_word(a, (*inode_counter)++); /* inode */
a = write_cpio_word(a, access_mode | 0100000 /* = S_IFREG */); /* mode */
a = write_cpio_word(a, target_dir_prefix_size + fname_size + 2); /* fname size */
a = write_cpio_word(a, 0); /* "crc" */
- memcpy(a, target_dir_prefix, target_dir_prefix_size);
- a += target_dir_prefix_size;
+ a = mempcpy(a, target_dir_prefix, target_dir_prefix_size);
*(a++) = '/';
a = mangle_filename(a, fname);
/* Pad to next multiple of 4 */
a = pad4(a, *cpio_buffer);
- memcpy(a, contents, contents_size);
- a += contents_size;
+ a = mempcpy(a, contents, contents_size);
/* Pad to next multiple of 4 */
a = pad4(a, *cpio_buffer);
*cpio_buffer = a = xrealloc(*cpio_buffer, *cpio_buffer_size, *cpio_buffer_size + l);
a = (char *) *cpio_buffer + *cpio_buffer_size;
- memcpy(a, "070701", 6); /* magic ID */
- a += 6;
+ a = mempcpy(a, "070701", 6); /* magic ID */
a = write_cpio_word(a, (*inode_counter)++); /* inode */
a = write_cpio_word(a, access_mode | 0040000 /* = S_IFDIR */); /* mode */
a = write_cpio_word(a, path_size + 1); /* fname size */
a = write_cpio_word(a, 0); /* "crc" */
- memcpy(a, path, path_size + 1);
- a += path_size + 1;
+ a = mempcpy(a, path, path_size + 1);
/* Pad to next multiple of 4 */
a = pad4(a, *cpio_buffer);
/* Order matters, the real initrd must come first, since it might include microcode updates
* which the kernel only looks for in the first cpio archive */
- memcpy(p, PHYSICAL_ADDRESS_TO_POINTER(initrd_base), initrd_size);
- p += initrd_size;
+ p = mempcpy(p, PHYSICAL_ADDRESS_TO_POINTER(initrd_base), initrd_size);
pad = ALIGN4(initrd_size) - initrd_size;
if (pad > 0) {
}
}
- if (credential_initrd) {
- memcpy(p, credential_initrd, credential_initrd_size);
- p += credential_initrd_size;
- }
-
- if (global_credential_initrd) {
- memcpy(p, global_credential_initrd, global_credential_initrd_size);
- p += global_credential_initrd_size;
- }
-
- if (sysext_initrd) {
- memcpy(p, sysext_initrd, sysext_initrd_size);
- p += sysext_initrd_size;
- }
+ if (credential_initrd)
+ p = mempcpy(p, credential_initrd, credential_initrd_size);
+ if (global_credential_initrd)
+ p = mempcpy(p, global_credential_initrd, global_credential_initrd_size);
+ if (sysext_initrd)
+ p = mempcpy(p, sysext_initrd, sysext_initrd_size);
assert((uint8_t*) PHYSICAL_ADDRESS_TO_POINTER(base) + n == p);
end_node = NextDevicePathNode(end_node);
size_t file_size = strsize16(file);
- size_t dp_size = ((uint8_t *) end_node - (uint8_t *) dp) + END_DEVICE_PATH_LENGTH;
+ size_t dp_size = (uint8_t *) end_node - (uint8_t *) dp;
/* Make a copy that can also hold a file media device path. */
- *ret_dp = xmalloc(dp_size + file_size + SIZE_OF_FILEPATH_DEVICE_PATH);
- memcpy(*ret_dp, dp, dp_size);
-
- /* Point dp to the end node of the copied device path. */
- dp = (EFI_DEVICE_PATH *) ((uint8_t *) *ret_dp + dp_size - END_DEVICE_PATH_LENGTH);
+ *ret_dp = xmalloc(dp_size + file_size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);
+ dp = mempcpy(*ret_dp, dp, dp_size);
/* Replace end node with file media device path. */
FILEPATH_DEVICE_PATH *file_dp = (FILEPATH_DEVICE_PATH *) dp;