Global: uses alignas where applicable

This commit is contained in:
李通洲
2026-02-09 16:22:17 +08:00
parent d2215f26ac
commit 1323d007d3
6 changed files with 13 additions and 6 deletions
+2 -1
View File
@@ -9,6 +9,7 @@
#endif
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdalign.h>
#ifdef __NetBSD__
typedef uint16_t efi_char;
@@ -23,7 +24,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result)
FF_AUTO_CLOSE_FD int efifd = open("/dev/efi", O_RDWR | O_CLOEXEC);
if (efifd < 0) return "open(/dev/efi) failed";
uint8_t buffer[2048];
alignas(uint16_t) uint8_t buffer[2048];
struct efi_var_ioc ioc = {
.vendor = EFI_GLOBAL_VARIABLE,
.data = buffer,
+3 -1
View File
@@ -2,11 +2,13 @@
#include "common/io.h"
#include "efi_helper.h"
#include <stdalign.h>
#define FF_EFIVARS_PATH_PREFIX "/sys/firmware/efi/efivars/"
const char* ffDetectBootmgr(FFBootmgrResult* result)
{
uint8_t buffer[2048];
alignas(uint16_t) uint8_t buffer[2048];
if (ffReadFileData(FF_EFIVARS_PATH_PREFIX "BootCurrent-" FF_EFI_GLOBAL_GUID, sizeof(buffer), buffer) != 6)
return "Failed to read efivar: BootCurrent";
+2 -1
View File
@@ -6,6 +6,7 @@
#include "common/mallocHelper.h"
#include "common/io.h"
#include <stdalign.h>
#include <windows.h>
#include "common/windows/nt.h"
#include <ntstatus.h>
@@ -17,7 +18,7 @@ static uint32_t getNumElements(const char* searchPath, DWORD type, const wchar_t
bool flag = ignore == NULL;
uint32_t counter = 0;
uint8_t buffer[64 * 1024] __attribute__((aligned(8))); // Required for WoA
alignas(8) uint8_t buffer[64 * 1024];
BOOLEAN firstScan = TRUE;
size_t ignoreLen = ignore ? wcslen(ignore) : 0;
@@ -2,6 +2,7 @@
#include "common/io.h"
#include "common/windows/unicode.h"
#include <stdalign.h>
#include <windows.h>
#include <winioctl.h>
@@ -135,7 +136,7 @@ static bool detectPhysicalDisk(const wchar_t* szDevice, FFlist* result, FFPhysic
}
{
uint8_t buffer[sizeof(GET_MEDIA_TYPES) + sizeof(DEVICE_MEDIA_INFO) * 7] = "";
alignas(GET_MEDIA_TYPES) uint8_t buffer[sizeof(GET_MEDIA_TYPES) + sizeof(DEVICE_MEDIA_INFO) * 7] = {};
GET_MEDIA_TYPES* gmt = (GET_MEDIA_TYPES*) buffer;
if(DeviceIoControl(
hDevice,
+2 -1
View File
@@ -2,13 +2,14 @@
#include <sys/stat.h>
#include <sys/swap.h>
#include <limits.h>
#include <stdalign.h>
enum { FFMaxNSwap = 8 };
const char* ffDetectSwap(FFlist* result)
{
char strings[FFMaxNSwap][PATH_MAX];
uint8_t buffer[sizeof(swaptbl_t) + sizeof(swapent_t) * (FFMaxNSwap - 1)] = {};
alignas(swaptbl_t) uint8_t buffer[sizeof(swaptbl_t) + sizeof(swapent_t) * (FFMaxNSwap - 1)] = {};
swaptbl_t* table = (swaptbl_t*) buffer;
table->swt_n = FFMaxNSwap;
for (int i = 0; i < FFMaxNSwap; ++i)
+2 -1
View File
@@ -6,10 +6,11 @@
#include <ntstatus.h>
#include <windows.h>
#include <psapi.h>
#include <stdalign.h>
const char* detectByNqsi(FFlist* result)
{
uint8_t buffer[4096];
alignas(SYSTEM_PAGEFILE_INFORMATION) uint8_t buffer[4096];
ULONG size = sizeof(buffer);
SYSTEM_PAGEFILE_INFORMATION* pstart = (SYSTEM_PAGEFILE_INFORMATION*) buffer;
if(!NT_SUCCESS(NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size)))