From: guenther Date: Fri, 7 Jan 2022 02:47:06 +0000 (+0000) Subject: hibernate_clear_signature() is only used by hibernate_resume(), so X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8cae4923c1f963ffa9eccc5aef6128da4b26206b;p=openbsd hibernate_clear_signature() is only used by hibernate_resume(), so pass in the already read hibernate_info instead of reading it again. ok deraadt@ --- diff --git a/sys/kern/subr_hibernate.c b/sys/kern/subr_hibernate.c index 22a79a25708..f60851846e6 100644 --- a/sys/kern/subr_hibernate.c +++ b/sys/kern/subr_hibernate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_hibernate.c,v 1.131 2022/01/07 02:26:53 guenther Exp $ */ +/* $OpenBSD: subr_hibernate.c,v 1.132 2022/01/07 02:47:07 guenther Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt @@ -918,23 +918,18 @@ hibernate_write_chunktable(union hibernate_info *hib) * guaranteed to not match any valid hib. */ int -hibernate_clear_signature(void) +hibernate_clear_signature(union hibernate_info *hib) { union hibernate_info blank_hiber_info; - union hibernate_info hib; /* Zero out a blank hiber_info */ memset(&blank_hiber_info, 0, sizeof(union hibernate_info)); - /* Get the signature block location */ - if (get_hibernate_info(&hib, 0)) - return (1); - /* Write (zeroed) hibernate info to disk */ DPRINTF("clearing hibernate signature block location: %lld\n", - hib.sig_offset); - if (hibernate_block_io(&hib, - hib.sig_offset, + hib->sig_offset); + if (hibernate_block_io(hib, + hib->sig_offset, DEV_BSIZE, (vaddr_t)&blank_hiber_info, 1)) printf("Warning: could not clear hibernate signature\n"); @@ -1160,7 +1155,7 @@ hibernate_resume(void) * We (possibly) found a hibernate signature. Clear signature first, * to prevent accidental resume or endless resume cycles later. */ - if (hibernate_clear_signature()) { + if (hibernate_clear_signature(&hib)) { DPRINTF("error clearing hibernate signature block\n"); splx(s); return; diff --git a/sys/sys/hibernate.h b/sys/sys/hibernate.h index be09102a5e9..2cccacf84aa 100644 --- a/sys/sys/hibernate.h +++ b/sys/sys/hibernate.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hibernate.h,v 1.42 2018/06/21 07:33:30 mlarkin Exp $ */ +/* $OpenBSD: hibernate.h,v 1.43 2022/01/07 02:47:06 guenther Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt @@ -138,7 +138,7 @@ int hibernate_block_io(union hibernate_info *, daddr_t, size_t, vaddr_t, int); int hibernate_write_signature(union hibernate_info *); int hibernate_write_chunktable(union hibernate_info *); int hibernate_write_chunks(union hibernate_info *); -int hibernate_clear_signature(void); +int hibernate_clear_signature(union hibernate_info *); int hibernate_compare_signature(union hibernate_info *, union hibernate_info *); void hibernate_resume(void);