3042bbebdd
https://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html This only works with clang, unfortunately gcc doesn't seem to implement the check (tested with gcc-8.2.1-5.fc29.x86_64). Simulated error: [2/3] Compiling C object 'systemd-nspawn@exe/src_nspawn_nspawn.c.o'. ../src/nspawn/nspawn.c:3179:45: warning: array argument is too small; contains 15 elements, callee requires at least 16 [-Warray-bounds] candidate = (uid_t) siphash24(arg_machine, strlen(arg_machine), hash_key); ^ ~~~~~~~~ ../src/basic/siphash24.h:24:64: note: callee declares array parameter as static here uint64_t siphash24(const void *in, size_t inlen, const uint8_t k[static 16]); ^~~~~~~~~~~~
36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/* SPDX-License-Identifier: LGPL-2.1+ */
|
|
|
|
#include <efi.h>
|
|
#include <efilib.h>
|
|
|
|
#include "util.h"
|
|
|
|
EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, CHAR16 uuid[static 37]) {
|
|
EFI_DEVICE_PATH *device_path;
|
|
|
|
/* export the device path this image is started from */
|
|
device_path = DevicePathFromHandle(handle);
|
|
if (device_path) {
|
|
_cleanup_freepool_ EFI_DEVICE_PATH *paths = NULL;
|
|
EFI_DEVICE_PATH *path;
|
|
|
|
paths = UnpackDevicePath(device_path);
|
|
for (path = paths; !IsDevicePathEnd(path); path = NextDevicePathNode(path)) {
|
|
HARDDRIVE_DEVICE_PATH *drive;
|
|
|
|
if (DevicePathType(path) != MEDIA_DEVICE_PATH)
|
|
continue;
|
|
if (DevicePathSubType(path) != MEDIA_HARDDRIVE_DP)
|
|
continue;
|
|
drive = (HARDDRIVE_DEVICE_PATH *)path;
|
|
if (drive->SignatureType != SIGNATURE_TYPE_GUID)
|
|
continue;
|
|
|
|
GuidToString(uuid, (EFI_GUID *)&drive->Signature);
|
|
return EFI_SUCCESS;
|
|
}
|
|
}
|
|
|
|
return EFI_NOT_FOUND;
|
|
}
|