Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1625442 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-04-18 18:50 +0200 |
| Last post | 2017-04-18 19:00 +0200 |
| Articles | 7 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/6] ACPI: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 18:50 +0200
[PATCH 6/6] ACPI-proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
[PATCH 2/6] ACPI-fan: Delete error messages for a failed memory allocation in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
[PATCH 5/6] ACPI-battery: Replace 16 seq_printf() calls by seq_puts() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
[PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
[PATCH 4/6] ACPI-APEI-EINJ: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
[PATCH 3/6] ACPI-nfit: Use devm_kcalloc() in nfit_mem_dcr_init() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-18 19:00 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 18:50 +0200 |
| Subject | [PATCH 0/6] ACPI: Fine-tuning for some function implementations |
| Message-ID | <txEue-8r4-19@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Tue, 18 Apr 2017 18:28:18 +0200 A few update suggestions were taken into account from static source code analysis. Markus Elfring (6): fan: Use devm_kcalloc() in acpi_fan_get_fps() fan: Delete error messages for a failed memory allocation in two functions nfit: Use devm_kcalloc() in nfit_mem_dcr_init() einj: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show() battery: Replace 16 seq_printf() calls by seq_puts() proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show() drivers/acpi/apei/einj.c | 25 +++++++++++++------------ drivers/acpi/battery.c | 34 +++++++++++++++++----------------- drivers/acpi/fan.c | 9 +++------ drivers/acpi/nfit/core.c | 8 +++++--- drivers/acpi/proc.c | 4 ++-- 5 files changed, 40 insertions(+), 40 deletions(-) -- 2.12.2
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 19:00 +0200 |
| Subject | [PATCH 6/6] ACPI-proc: Replace two seq_printf() calls by seq_puts() in acpi_system_wakeup_device_seq_show() |
| Message-ID | <txEDT-8uq-1@gated-at.bofh.it> |
| In reply to | #1625442 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 18:13:55 +0200
Strings which did not contain data format specifications should be put
into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/proc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/proc.c b/drivers/acpi/proc.c
index a34669cc823b..f17d5eb29609 100644
--- a/drivers/acpi/proc.c
+++ b/drivers/acpi/proc.c
@@ -23,7 +23,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
{
struct list_head *node, *next;
- seq_printf(seq, "Device\tS-state\t Status Sysfs node\n");
+ seq_puts(seq, "Device\tS-state\t Status Sysfs node\n");
mutex_lock(&acpi_device_lock);
list_for_each_safe(node, next, &acpi_wakeup_device_list) {
@@ -55,7 +55,7 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
if (&entry->node !=
dev->physical_node_list.next)
- seq_printf(seq, "\t\t");
+ seq_puts(seq, "\t\t");
seq_printf(seq, "%c%-8s %s:%s\n",
dev->wakeup.flags.run_wake ? '*' : ' ',
--
2.12.2
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 19:00 +0200 |
| Subject | [PATCH 2/6] ACPI-fan: Delete error messages for a failed memory allocation in two functions |
| Message-ID | <txEDU-8uq-5@gated-at.bofh.it> |
| In reply to | #1625442 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:10:40 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: Possible unnecessary 'out of memory' message
Thus remove such statements here.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/fan.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 92878c7c523b..daa8f28a4b0e 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -301,7 +301,6 @@ static int acpi_fan_get_fps(struct acpi_device *device)
fan->fps = devm_kcalloc(&device->dev, fan->fps_count, sizeof(*fan->fps),
GFP_KERNEL);
if (!fan->fps) {
- dev_err(&device->dev, "Not enough memory\n");
status = -ENOMEM;
goto err;
}
@@ -334,10 +333,9 @@ static int acpi_fan_probe(struct platform_device *pdev)
char *name;
fan = devm_kzalloc(&pdev->dev, sizeof(*fan), GFP_KERNEL);
- if (!fan) {
- dev_err(&device->dev, "No memory for fan\n");
+ if (!fan)
return -ENOMEM;
- }
+
device->driver_data = fan;
platform_set_drvdata(pdev, fan);
--
2.12.2
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 19:00 +0200 |
| Subject | [PATCH 5/6] ACPI-battery: Replace 16 seq_printf() calls by seq_puts() |
| Message-ID | <txEDU-8uq-11@gated-at.bofh.it> |
| In reply to | #1625442 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 18:04:22 +0200
Strings which did not contain data format specifications should be put
into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/battery.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 4ef1e4624b2b..d217e1c18b42 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -825,14 +825,14 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
if (!acpi_battery_present(battery))
goto end;
if (battery->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "design capacity: unknown\n");
+ seq_puts(seq, "design capacity: unknown\n");
else
seq_printf(seq, "design capacity: %d %sh\n",
battery->design_capacity,
acpi_battery_units(battery));
if (battery->full_charge_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "last full capacity: unknown\n");
+ seq_puts(seq, "last full capacity: unknown\n");
else
seq_printf(seq, "last full capacity: %d %sh\n",
battery->full_charge_capacity,
@@ -842,7 +842,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
(!battery->technology)?"non-":"");
if (battery->design_voltage == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "design voltage: unknown\n");
+ seq_puts(seq, "design voltage: unknown\n");
else
seq_printf(seq, "design voltage: %d mV\n",
battery->design_voltage);
@@ -865,7 +865,7 @@ static int acpi_battery_print_info(struct seq_file *seq, int result)
seq_printf(seq, "OEM info: %s\n", battery->oem_info);
end:
if (result)
- seq_printf(seq, "ERROR: Unable to read battery info\n");
+ seq_puts(seq, "ERROR: Unable to read battery info\n");
return result;
}
@@ -884,34 +884,34 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)
seq_printf(seq, "capacity state: %s\n",
(battery->state & 0x04) ? "critical" : "ok");
if ((battery->state & 0x01) && (battery->state & 0x02))
- seq_printf(seq,
- "charging state: charging/discharging\n");
+ seq_puts(seq,
+ "charging state: charging/discharging\n");
else if (battery->state & 0x01)
- seq_printf(seq, "charging state: discharging\n");
+ seq_puts(seq, "charging state: discharging\n");
else if (battery->state & 0x02)
- seq_printf(seq, "charging state: charging\n");
+ seq_puts(seq, "charging state: charging\n");
else
- seq_printf(seq, "charging state: charged\n");
+ seq_puts(seq, "charging state: charged\n");
if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "present rate: unknown\n");
+ seq_puts(seq, "present rate: unknown\n");
else
seq_printf(seq, "present rate: %d %s\n",
battery->rate_now, acpi_battery_units(battery));
if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "remaining capacity: unknown\n");
+ seq_puts(seq, "remaining capacity: unknown\n");
else
seq_printf(seq, "remaining capacity: %d %sh\n",
battery->capacity_now, acpi_battery_units(battery));
if (battery->voltage_now == ACPI_BATTERY_VALUE_UNKNOWN)
- seq_printf(seq, "present voltage: unknown\n");
+ seq_puts(seq, "present voltage: unknown\n");
else
seq_printf(seq, "present voltage: %d mV\n",
battery->voltage_now);
end:
if (result)
- seq_printf(seq, "ERROR: Unable to read battery state\n");
+ seq_puts(seq, "ERROR: Unable to read battery state\n");
return result;
}
@@ -924,18 +924,18 @@ static int acpi_battery_print_alarm(struct seq_file *seq, int result)
goto end;
if (!acpi_battery_present(battery)) {
- seq_printf(seq, "present: no\n");
+ seq_puts(seq, "present: no\n");
goto end;
}
- seq_printf(seq, "alarm: ");
+ seq_puts(seq, "alarm: ");
if (!battery->alarm)
- seq_printf(seq, "unsupported\n");
+ seq_puts(seq, "unsupported\n");
else
seq_printf(seq, "%u %sh\n", battery->alarm,
acpi_battery_units(battery));
end:
if (result)
- seq_printf(seq, "ERROR: Unable to read battery alarm\n");
+ seq_puts(seq, "ERROR: Unable to read battery alarm\n");
return result;
}
--
2.12.2
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 19:00 +0200 |
| Subject | [PATCH 1/6] ACPI-fan: Use devm_kcalloc() in acpi_fan_get_fps() |
| Message-ID | <txEDU-8uq-19@gated-at.bofh.it> |
| In reply to | #1625442 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:00:39 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/fan.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 6cf4988206f2..92878c7c523b 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -298,8 +298,7 @@ static int acpi_fan_get_fps(struct acpi_device *device)
}
fan->fps_count = obj->package.count - 1; /* minus revision field */
- fan->fps = devm_kzalloc(&device->dev,
- fan->fps_count * sizeof(struct acpi_fan_fps),
+ fan->fps = devm_kcalloc(&device->dev, fan->fps_count, sizeof(*fan->fps),
GFP_KERNEL);
if (!fan->fps) {
dev_err(&device->dev, "Not enough memory\n");
--
2.12.2
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 19:00 +0200 |
| Subject | [PATCH 4/6] ACPI-APEI-EINJ: Replace 12 seq_printf() calls by seq_puts() in available_error_type_show() |
| Message-ID | <txEDV-8uq-21@gated-at.bofh.it> |
| In reply to | #1625442 |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Tue, 18 Apr 2017 17:50:12 +0200 Strings which did not contain data format specifications should be put into a sequence. Thus use the corresponding function "seq_puts". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/acpi/apei/einj.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index ec50c32ea3da..b2bb7c764cdb 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -580,29 +580,30 @@ static int available_error_type_show(struct seq_file *m, void *v) if (rc) return rc; if (available_error_type & 0x0001) - seq_printf(m, "0x00000001\tProcessor Correctable\n"); + seq_puts(m, "0x00000001\tProcessor Correctable\n"); if (available_error_type & 0x0002) - seq_printf(m, "0x00000002\tProcessor Uncorrectable non-fatal\n"); + seq_puts(m, "0x00000002\tProcessor Uncorrectable non-fatal\n"); if (available_error_type & 0x0004) - seq_printf(m, "0x00000004\tProcessor Uncorrectable fatal\n"); + seq_puts(m, "0x00000004\tProcessor Uncorrectable fatal\n"); if (available_error_type & 0x0008) - seq_printf(m, "0x00000008\tMemory Correctable\n"); + seq_puts(m, "0x00000008\tMemory Correctable\n"); if (available_error_type & 0x0010) - seq_printf(m, "0x00000010\tMemory Uncorrectable non-fatal\n"); + seq_puts(m, "0x00000010\tMemory Uncorrectable non-fatal\n"); if (available_error_type & 0x0020) - seq_printf(m, "0x00000020\tMemory Uncorrectable fatal\n"); + seq_puts(m, "0x00000020\tMemory Uncorrectable fatal\n"); if (available_error_type & 0x0040) - seq_printf(m, "0x00000040\tPCI Express Correctable\n"); + seq_puts(m, "0x00000040\tPCI Express Correctable\n"); if (available_error_type & 0x0080) - seq_printf(m, "0x00000080\tPCI Express Uncorrectable non-fatal\n"); + seq_puts(m, + "0x00000080\tPCI Express Uncorrectable non-fatal\n"); if (available_error_type & 0x0100) - seq_printf(m, "0x00000100\tPCI Express Uncorrectable fatal\n"); + seq_puts(m, "0x00000100\tPCI Express Uncorrectable fatal\n"); if (available_error_type & 0x0200) - seq_printf(m, "0x00000200\tPlatform Correctable\n"); + seq_puts(m, "0x00000200\tPlatform Correctable\n"); if (available_error_type & 0x0400) - seq_printf(m, "0x00000400\tPlatform Uncorrectable non-fatal\n"); + seq_puts(m, "0x00000400\tPlatform Uncorrectable non-fatal\n"); if (available_error_type & 0x0800) - seq_printf(m, "0x00000800\tPlatform Uncorrectable fatal\n"); + seq_puts(m, "0x00000800\tPlatform Uncorrectable fatal\n"); return 0; } -- 2.12.2
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-04-18 19:00 +0200 |
| Subject | [PATCH 3/6] ACPI-nfit: Use devm_kcalloc() in nfit_mem_dcr_init() |
| Message-ID | <txEDV-8uq-25@gated-at.bofh.it> |
| In reply to | #1625442 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Apr 2017 17:30:15 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "devm_kcalloc".
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/acpi/nfit/core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 462e77272272..1aa625dc424a 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -809,9 +809,11 @@ static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
continue;
nfit_mem->nfit_flush = nfit_flush;
flush = nfit_flush->flush;
- nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev,
- flush->hint_count
- * sizeof(struct resource), GFP_KERNEL);
+ nfit_mem->flush_wpq
+ = devm_kcalloc(acpi_desc->dev,
+ flush->hint_count,
+ sizeof(*nfit_mem->flush_wpq),
+ GFP_KERNEL);
if (!nfit_mem->flush_wpq)
return -ENOMEM;
for (i = 0; i < flush->hint_count; i++) {
--
2.12.2
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web