Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ clean-toplevel:
@rm -vf efivar.spec vgcore.* core.*
@$(MAKE) -C tests clean

compile_commands.json : Makefile
make clean
bear -- make COMPILER=clang test all

test : all
@$(MAKE) -C tests

Expand Down
5 changes: 3 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ util-makeguids.c : util.c

ALL_SOURCES=$(LIBEFISEC_SOURCES) $(LIBEFIBOOT_SOURCES) $(LIBEFIVAR_SOURCES) \
$(MAKEGUIDS_SOURCES) $(GENERATED_SOURCES) $(EFIVAR_SOURCES) \
$(EFISECDB_SOURCES) \
$(sort $(wildcard include/efivar/*.h))

ifneq ($(MAKECMDGOALS),clean)
Expand Down Expand Up @@ -118,12 +119,12 @@ libefisec.so : | libefisec.map
libefisec.so : private MAP=libefisec.map

efisecdb : $(EFISECDB_OBJECTS) | libefisec.so
efisecdb : private LIBS=efivar efisec dl
efisecdb : private LIBS=crypto efivar efisec dl

efisecdb-static : $(EFISECDB_OBJECTS)
efisecdb-static : $(patsubst %.o,%.static.o,$(LIBEFISEC_OBJECTS) $(LIBEFIVAR_OBJECTS))
efisecdb-static : | $(GENERATED_SOURCES)
efisecdb-static : private LIBS=dl
efisecdb-static : private LIBS=crypto dl

thread-test : libefivar.so
# make sure we don't propagate CFLAGS to object files used by 'libefivar.so'
Expand Down
4 changes: 1 addition & 3 deletions src/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* Copyright Peter Jones <pjones@redhat.com>
*/

#ifndef COMPILER_H_
#define COMPILER_H_
#pragma once

/* GCC version checking borrowed from glibc. */
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
Expand Down Expand Up @@ -80,5 +79,4 @@
#define ALIGNMENT_PADDING(value, align) ((align - (value % align)) % align)
#define ALIGN_UP(value, align) ((value) + ALIGNMENT_PADDING(value, align))

#endif /* !COMPILER_H_ */
// vim:fenc=utf-8:tw=75:noet
7 changes: 1 addition & 6 deletions src/crc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* crc32.h - headers for crc32
*
*/

#ifndef _CRC32_H
#define _CRC32_H
#pragma once

#include <stdint.h>

Expand Down Expand Up @@ -34,7 +32,4 @@ efi_crc32(const void *buf, unsigned long len)
return (crc32(buf, len, ~0L) ^ ~0L);
}


#endif /* _CRC32_H */

// vim:fenc=utf-8:tw=75:noet
2 changes: 1 addition & 1 deletion src/creator.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012-2015 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <fcntl.h>
#include <inttypes.h>
Expand Down
5 changes: 1 addition & 4 deletions src/diag.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* diag.h - Set up appropriate -W flags based on which compiler is in use
* Copyright Peter Jones <pjones@redhat.com>
*/

#ifndef PRIVATE_DIAG_H_
#define PRIVATE_DIAG_H_
#pragma once

#if defined(__clang__)
#pragma clang diagnostic ignored "-Wpointer-bool-conversion"
Expand Down Expand Up @@ -55,5 +53,4 @@
#endif /* !defined(EFIVAR_SYNTAX_CHECKING) */
#endif

#endif /* !PRIVATE_DIAG_H_ */
// vim:fenc=utf-8:tw=75:noet
2 changes: 1 addition & 1 deletion src/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2000-2001 Dell Computer Corporation <Matt_Domsch@dell.com>
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <errno.h>
#include <fcntl.h>
Expand Down
5 changes: 1 addition & 4 deletions src/disk.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* Copyright 2012-2015 Red Hat, Inc.
* Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
*/
#ifndef _EFIBOOT_DISK_H
#define _EFIBOOT_DISK_H
#pragma once

extern bool HIDDEN is_partitioned(int fd);

extern HIDDEN ssize_t make_hd_dn(uint8_t *buf, ssize_t size, int fd,
int32_t partition, uint32_t options);

#endif /* _EFIBOOT_DISK_H */

// vim:fenc=utf-8:tw=75:noet
2 changes: 1 addition & 1 deletion src/dp-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012-2019 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <errno.h>
#include <inttypes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/dp-hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012-2015 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <errno.h>
#include <inttypes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/dp-media.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012-2015 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <errno.h>
#include <inttypes.h>
Expand Down
2 changes: 1 addition & 1 deletion src/dp-message.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012-2015 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <arpa/inet.h>
#include <errno.h>
Expand Down
2 changes: 1 addition & 1 deletion src/dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012-2015 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <inttypes.h>
#include <stdlib.h>
Expand Down
5 changes: 1 addition & 4 deletions src/dp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* libefivar - library for the manipulation of EFI variables
* Copyright 2012-2015 Red Hat, Inc.
*/
#ifndef _EFIVAR_INTERNAL_DP_H
#define _EFIVAR_INTERNAL_DP_H
#pragma once

#include <alloca.h>
#include <stdarg.h>
Expand Down Expand Up @@ -179,6 +178,4 @@ extern ssize_t _format_bios_boot_dn(unsigned char *buf, size_t size, const_efidp
#define format_bios_boot_dn(buf, size, off, dp) \
format_helper_2(_format_bios_boot_dn, buf, size, off, dp)

#endif /* _EFIVAR_INTERNAL_DP_H */

// vim:fenc=utf-8:tw=75:noet
10 changes: 3 additions & 7 deletions src/efiboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
* efiboot.h
* Copyright 2018 Peter Jones <pjones@redhat.com>
*/
#pragma once

#ifndef PRIVATE_EFIBOOT_H_
#define PRIVATE_EFIBOOT_H_

#include "efivar.h"
#include <efivar/efiboot.h>

#endif /* !PRIVATE_EFIBOOT_H_ */
#include "efivar.h" // IWYU pragma: export
#include "efivar/efiboot.h" // IWYU pragma: export

// vim:fenc=utf-8:tw=75:noet
42 changes: 23 additions & 19 deletions src/efisec.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@
* efisec.h
* Copyright 2018 Peter Jones <pjones@redhat.com>
*/
#pragma once

#ifndef PRIVATE_EFISEC_H_
#define PRIVATE_EFISEC_H_
#include "fix_coverity.h" // IWYU pragma: keep

#include "fix_coverity.h"
#include <err.h> // IWYU pragma: export
#include <errno.h> // IWYU pragma: export
#include <inttypes.h> // IWYU pragma: export
#include <stdbool.h> // IWYU pragma: export
#include <stddef.h> // IWYU pragma: export
#include <stdlib.h> // IWYU pragma: export
#include <stdint.h> // IWYU pragma: export
#include <stdio.h> // IWYU pragma: export
#include <string.h> // IWYU pragma: export
#include <sys/param.h> // IWYU pragma: export
#include <unistd.h> // IWYU pragma: export

#include <efivar/efisec.h>
#include <err.h>
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#include <unistd.h>
#include "efivar/efivar-types.h" // IWYU pragma: export
#include "efivar/efivar-guids.h" // IWYU pragma: export
#include "efivar/efivar.h" // IWYU pragma: export

#include "efivar.h"
#include "esl-iter.h"
#include "secdb.h"
#include "x509.h"
#include "efivar/efisec-types.h" // IWYU pragma: export
#include "efivar/efisec-secdb.h" // IWYU pragma: export
#include "efivar/efisec.h" // IWYU pragma: export

#endif /* !PRIVATE_EFISEC_H_ */
#include "efivar.h" // IWYU pragma: export
#include "esl-iter.h" // IWYU pragma: export
#include "secdb.h" // IWYU pragma: export
#include "x509.h" // IWYU pragma: export

// vim:fenc=utf-8:tw=75:noet
18 changes: 11 additions & 7 deletions src/efisecdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
* Copyright Peter Jones <pjones@redhat.com>
* Copyright Red Hat, Inc.
*/
#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep
Comment thread
vathpela marked this conversation as resolved.

#include "linux.h"
Comment thread
vathpela marked this conversation as resolved.
#include <err.h>
#include <errno.h>
#include <fcntl.h>
Expand Down Expand Up @@ -38,17 +37,22 @@ struct hash_param {

static struct hash_param hash_params[] = {
{.name = "sha512",
.algorithm = SHA512,
.algorithm = EFI_SECDB_TYPE_SHA512,
.size = 64,
.def = false,
},
{.name = "sha384",
.algorithm = EFI_SECDB_TYPE_SHA384,
.size = 48,
.def = false,
},
{.name = "sha256",
.algorithm = SHA256,
.algorithm = EFI_SECDB_TYPE_SHA256,
.size = 32,
.def = true,
},
{.name = "sha1",
.algorithm = SHA1,
.algorithm = EFI_SECDB_TYPE_SHA1,
.size = 20,
.def = false,
},
Expand Down Expand Up @@ -145,7 +149,7 @@ usage(int status)
" -a, --add following hashes or certs are to be added (default)\n"
" -r, --remove following hashes or certs are to be removed\n"
" -g, --owner-guid=<GUID> following added entries use GUID as the owner\n"
" -h, --hash=<hash> hash value to add (\n"
" -h, --hash=<hash> hash value to add\n"
" -t, --type=<hash-type> hash type to add (\"help\" lists options)\n"
" -c, --certificate=<file> certificate file to add\n"
" -L, --list-guids list well known guids\n",
Expand Down Expand Up @@ -394,7 +398,7 @@ main(int argc, char *argv[])
mode == ADD ? "adding" : "removing", datasz);
if (mode == ADD)
wants_add_actions = true;
add_action(&actions, mode, &owner, X509_CERT, data, datasz);
add_action(&actions, mode, &owner, EFI_SECDB_TYPE_X509_CERT, data, datasz);
break;
case 'd':
dump = true;
Expand Down
2 changes: 1 addition & 1 deletion src/efivar.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <ctype.h>
#include <err.h>
Expand Down
10 changes: 3 additions & 7 deletions src/efivar.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
* efivar.h
* Copyright 2018 Peter Jones <pjones@redhat.com>
*/

#ifndef PRIVATE_EFIVAR_H_
#define PRIVATE_EFIVAR_H_
#pragma once

#pragma GCC diagnostic warning "-Wcpp"

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <efivar/efivar.h>
#include "efivar/efivar.h"

#include "compiler.h"
#include "diag.h"
Expand All @@ -31,6 +29,4 @@
#include "path-helpers.h"
#include "makeguids.h"

#endif /* !PRIVATE_EFIVAR_H_ */

// vim:fenc=utf-8:tw=75:noet
5 changes: 1 addition & 4 deletions src/efivar_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
*
* Author: Peter Jones <pjones@redhat.com>
*/
#ifndef _EFIVAR_ENDIAN_H
#define _EFIVAR_ENDIAN_H
#pragma once

#include <endian.h>

Expand Down Expand Up @@ -37,6 +36,4 @@
#define le64_to_cpu(x) ((uint64_t)__builtin_bswap64(x))
#endif

#endif /* _EFIVAR_ENDIAN_H */

// vim:fenc=utf-8:tw=75:noet
2 changes: 1 addition & 1 deletion src/efivarfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2012-2013 Red Hat, Inc.
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <err.h>
#include <errno.h>
Expand Down
2 changes: 1 addition & 1 deletion src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2000-2001 Dell Computer Corporation <Matt_Domsch@dell.com>
*/

#include "fix_coverity.h"
#include "fix_coverity.h" // IWYU pragma: keep

#include <errno.h>
#include <stdarg.h>
Expand Down
Loading
Loading