From: Pavel Machek <pavel@ucw.cz>
To: Andrew Morton <akpm@zip.com.au>,
kernel list <linux-kernel@vger.kernel.org>,
Rusty trivial patch monkey Russell <trivial@rustcorp.com.au>
Subject: More cleanups for swsusp
Date: Tue, 20 Jan 2004 23:52:19 +0100 [thread overview]
Message-ID: <20040120225219.GA19190@elf.ucw.cz> (raw)
Hi!
This fixes codingstyle a bit, converts "can not happen" panic into
BUG_ON (fill_suspend_header() allocates no memory so panic is
meaningless) and adds check for sizeof (struct link) [if that is not
PAGE_SIZE, we have *bad* problem, better check early]. Please apply,
Pavel
Index: linux/kernel/power/swsusp.c
===================================================================
--- linux.orig/kernel/power/swsusp.c 2004-01-13 22:52:40.000000000 +0100
+++ linux/kernel/power/swsusp.c 2004-01-09 20:33:05.000000000 +0100
@@ -340,14 +344,14 @@
printk("H");
BUG_ON (sizeof(struct suspend_header) > PAGE_SIZE-sizeof(swp_entry_t));
BUG_ON (sizeof(union diskpage) != PAGE_SIZE);
+ BUG_ON (sizeof(struct link) != PAGE_SIZE);
if (!(entry = get_swap_page()).val)
panic( "\nNot enough swapspace when writing header" );
if (swapfile_used[swp_type(entry)] != SWAPFILE_SUSPEND)
panic("\nNot enough swapspace for header on suspend device" );
cur = (void *) buffer;
- if (fill_suspend_header(&cur->sh))
- panic("\nOut of memory while writing header");
+ BUG_ON (fill_suspend_header(&cur->sh));
cur->link.next = prev;
@@ -856,23 +837,23 @@
static int sanity_check_failed(char *reason)
{
- printk(KERN_ERR "%s%s\n",name_resume,reason);
+ printk(KERN_ERR "%s%s\n", name_resume, reason);
return -EPERM;
}
static int sanity_check(struct suspend_header *sh)
{
- if(sh->version_code != LINUX_VERSION_CODE)
+ if (sh->version_code != LINUX_VERSION_CODE)
return sanity_check_failed("Incorrect kernel version");
- if(sh->num_physpages != num_physpages)
+ if (sh->num_physpages != num_physpages)
return sanity_check_failed("Incorrect memory size");
- if(strncmp(sh->machine, system_utsname.machine, 8))
+ if (strncmp(sh->machine, system_utsname.machine, 8))
return sanity_check_failed("Incorrect machine type");
- if(strncmp(sh->version, system_utsname.version, 20))
+ if (strncmp(sh->version, system_utsname.version, 20))
return sanity_check_failed("Incorrect version");
- if(sh->num_cpus != num_online_cpus())
+ if (sh->num_cpus != num_online_cpus())
return sanity_check_failed("Incorrect number of cpus");
- if(sh->page_size != PAGE_SIZE)
+ if (sh->page_size != PAGE_SIZE)
return sanity_check_failed("Incorrect PAGE_SIZE");
return 0;
}
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
--
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
next reply other threads:[~2004-01-20 22:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-20 22:52 Pavel Machek [this message]
2004-01-20 23:13 ` More cleanups for swsusp Andrew Morton
2004-01-20 23:25 ` Pavel Machek
2004-01-21 5:10 ` Rusty Russell
2004-01-22 0:17 ` Pavel Machek
2004-01-21 5:14 ` Rusty Russell
2004-01-21 5:30 ` Andrew Morton
2004-01-21 18:39 ` Matt Mackall
2004-01-22 2:03 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040120225219.GA19190@elf.ucw.cz \
--to=pavel@ucw.cz \
--cc=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=trivial@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox