From: Len Brown <len.brown@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>, Len Brown <len.brown@intel.com>
Subject: [PATCH 23/25] PNP: remove null pointer checks
Date: Fri, 24 Aug 2007 03:21:10 -0400 [thread overview]
Message-ID: <11879401002195-git-send-email-len.brown@intel.com> (raw)
Message-ID: <b173491339b9ae7f1322241ce6228c1268513a39.1187939443.git.len.brown@intel.com> (raw)
In-Reply-To: <11879400984017-git-send-email-len.brown@intel.com>
In-Reply-To: <3c1d36da1d5ed36979340efd233ddaacc45b0a02.1187939442.git.len.brown@intel.com>
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
Remove some null pointer checks. Null pointers in these areas indicate
programming errors, and I think it's better to oops immediately rather
than return an error that is easily ignored.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Adam Belay <abelay@novell.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
drivers/pnp/core.c | 7 +------
drivers/pnp/driver.c | 4 ----
drivers/pnp/isapnp/core.c | 2 +-
drivers/pnp/manager.c | 23 -----------------------
drivers/pnp/resource.c | 26 --------------------------
5 files changed, 2 insertions(+), 60 deletions(-)
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index 61066fd..d5964fe 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -52,9 +52,6 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
int nodenum;
struct list_head *pos;
- if (!protocol)
- return -EINVAL;
-
INIT_LIST_HEAD(&protocol->devices);
INIT_LIST_HEAD(&protocol->cards);
nodenum = 0;
@@ -94,8 +91,6 @@ static void pnp_free_ids(struct pnp_dev *dev)
struct pnp_id *id;
struct pnp_id *next;
- if (!dev)
- return;
id = dev->id;
while (id) {
next = id->next;
@@ -143,7 +138,7 @@ int __pnp_add_device(struct pnp_dev *dev)
*/
int pnp_add_device(struct pnp_dev *dev)
{
- if (!dev || !dev->protocol || dev->card)
+ if (dev->card)
return -EINVAL;
dev->dev.parent = &dev->protocol->dev;
sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number,
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index 9be01b0..2fa64a6 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -232,10 +232,6 @@ int pnp_add_id(struct pnp_id *id, struct pnp_dev *dev)
{
struct pnp_id *ptr;
- if (!id)
- return -EINVAL;
- if (!dev)
- return -EINVAL;
id->next = NULL;
ptr = dev->id;
while (ptr && ptr->next)
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 1a0d33a..b035d60 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -1040,7 +1040,7 @@ static int isapnp_set_resources(struct pnp_dev *dev,
static int isapnp_disable_resources(struct pnp_dev *dev)
{
- if (!dev || !dev->active)
+ if (!dev->active)
return -EINVAL;
isapnp_cfg_begin(dev->card->number, dev->number);
isapnp_deactivate(dev->number);
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 329dc6c..0826287 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -21,9 +21,6 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
resource_size_t *start, *end;
unsigned long *flags;
- if (!dev || !rule)
- return -EINVAL;
-
if (idx >= PNP_MAX_PORT) {
pnp_err
("More than 4 ports is incompatible with pnp specifications.");
@@ -66,9 +63,6 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
resource_size_t *start, *end;
unsigned long *flags;
- if (!dev || !rule)
- return -EINVAL;
-
if (idx >= PNP_MAX_MEM) {
pnp_err
("More than 8 mems is incompatible with pnp specifications.");
@@ -127,9 +121,6 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2
};
- if (!dev || !rule)
- return -EINVAL;
-
if (idx >= PNP_MAX_IRQ) {
pnp_err
("More than 2 irqs is incompatible with pnp specifications.");
@@ -181,9 +172,6 @@ static int pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
1, 3, 5, 6, 7, 0, 2, 4
};
- if (!dev || !rule)
- return -EINVAL;
-
if (idx >= PNP_MAX_DMA) {
pnp_err
("More than 2 dmas is incompatible with pnp specifications.");
@@ -410,8 +398,6 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
int i;
struct pnp_resource_table *bak;
- if (!dev || !res)
- return -EINVAL;
if (!pnp_can_configure(dev))
return -ENODEV;
bak = pnp_alloc(sizeof(struct pnp_resource_table));
@@ -460,9 +446,6 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
struct pnp_option *dep;
int i = 1;
- if (!dev)
- return -EINVAL;
-
if (!pnp_can_configure(dev)) {
pnp_dbg("Device %s does not support resource configuration.",
dev->dev.bus_id);
@@ -541,8 +524,6 @@ int pnp_activate_dev(struct pnp_dev *dev)
{
int error;
- if (!dev)
- return -EINVAL;
if (dev->active)
return 0; /* the device is already active */
@@ -568,8 +549,6 @@ int pnp_disable_dev(struct pnp_dev *dev)
{
int error;
- if (!dev)
- return -EINVAL;
if (!dev->active)
return 0; /* the device is already disabled */
@@ -596,8 +575,6 @@ int pnp_disable_dev(struct pnp_dev *dev)
void pnp_resource_change(struct resource *resource, resource_size_t start,
resource_size_t size)
{
- if (resource == NULL)
- return;
resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET);
resource->start = start;
resource->end = start + size - 1;
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index ea6ec14..ef12869 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -47,9 +47,6 @@ struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev)
{
struct pnp_option *option;
- if (!dev)
- return NULL;
-
option = pnp_build_option(PNP_RES_PRIORITY_PREFERRED);
/* this should never happen but if it does we'll try to continue */
@@ -64,9 +61,6 @@ struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
{
struct pnp_option *option;
- if (!dev)
- return NULL;
-
option = pnp_build_option(priority);
if (dev->dependent) {
@@ -83,11 +77,6 @@ int pnp_register_irq_resource(struct pnp_option *option, struct pnp_irq *data)
{
struct pnp_irq *ptr;
- if (!option)
- return -EINVAL;
- if (!data)
- return -EINVAL;
-
ptr = option->irq;
while (ptr && ptr->next)
ptr = ptr->next;
@@ -112,11 +101,6 @@ int pnp_register_dma_resource(struct pnp_option *option, struct pnp_dma *data)
{
struct pnp_dma *ptr;
- if (!option)
- return -EINVAL;
- if (!data)
- return -EINVAL;
-
ptr = option->dma;
while (ptr && ptr->next)
ptr = ptr->next;
@@ -132,11 +116,6 @@ int pnp_register_port_resource(struct pnp_option *option, struct pnp_port *data)
{
struct pnp_port *ptr;
- if (!option)
- return -EINVAL;
- if (!data)
- return -EINVAL;
-
ptr = option->port;
while (ptr && ptr->next)
ptr = ptr->next;
@@ -152,11 +131,6 @@ int pnp_register_mem_resource(struct pnp_option *option, struct pnp_mem *data)
{
struct pnp_mem *ptr;
- if (!option)
- return -EINVAL;
- if (!data)
- return -EINVAL;
-
ptr = option->mem;
while (ptr && ptr->next)
ptr = ptr->next;
--
1.5.3.rc6.17.g1911
next prev parent reply other threads:[~2007-08-24 7:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-24 7:20 ACPI patches for Linux-2.6.23-rc3 Len Brown
2007-08-24 7:20 ` [PATCH 01/25] ACPI: thermal: clean up MODULE_PARM_DESC newlines Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 02/25] ACPI: thermal: create "thermal.crt=C" bootparam Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 03/25] Revert "ACPI: Battery: Synchronize battery operations." Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 04/25] ACPI: thermal: set "thermal.nocrt" via DMI on Gigabyte GA-7ZX Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 05/25] ACPI: boot correctly with "nosmp" or "maxcpus=0" Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 06/25] Subject: "ACPI handle has no context!" should be KERN_DEBUG Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 08/25] ACPI: Schedule /proc/acpi/event for removal Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 09/25] ACPI: Fix a warning of discarding qualifiers from pointer target type Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 10/25] ACPI: video: Add keycode for ACPI video driver hotkey events Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 11/25] ACPI video hotkey: remove invalid events handler for video output devices Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:20 ` [PATCH 12/25] ACPI video hotkey: export ACPI video hotkey events via input layer Len Brown
2007-08-24 7:20 ` Len Brown
2007-08-24 7:21 ` [PATCH 13/25] ACPI: EC: revert fix for bugzilla 8709 Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 14/25] sony-laptop: enable Vaio FZ events Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 15/25] sony-laptop: call sonypi_compat_init earlier Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 16/25] asus-laptop: Fix rmmod of asus_laptop Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 17/25] ACPI: enable GPEs before calling _WAK on resume Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 18/25] PNP: fix up after Lindent Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 19/25] PNPACPI: simplify irq_flags() Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 20/25] PNPACPI: remove unnecessary casts of "void *" Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 21/25] ISAPNP: removed unused isapnp_detected and ISAPNP_DEBUG Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 22/25] PNP: remove MODULE infrastructure Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` Len Brown [this message]
2007-08-24 7:21 ` [PATCH 23/25] PNP: remove null pointer checks Len Brown
2007-08-24 7:21 ` [PATCH 24/25] make drivers/acpi/scan.c:create_modalias() static Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 7:21 ` [PATCH 25/25] ACPI: fix ia64 allnoconfig build Len Brown
2007-08-24 7:21 ` Len Brown
2007-08-24 8:07 ` ACPI patches for Linux-2.6.23-rc3 Zhang Rui
2007-08-24 23:37 ` Len Brown
2007-08-25 5:26 ` Zhang Rui
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=11879401002195-git-send-email-len.brown@intel.com \
--to=len.brown@intel.com \
--cc=bjorn.helgaas@hp.com \
--cc=linux-acpi@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.