diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-02-27 00:12:38 -0500 |
---|---|---|
committer | Steven Rostedt <srostedt@redhat.com> | 2009-02-27 00:12:38 -0500 |
commit | 85a2f9b46f8cd8aaa11c64c715e1ea3ec27ec486 (patch) | |
tree | 76079c21b3bb5763c19eb617f9e29139789cc903 /kernel/trace/trace.c | |
parent | d8e83d26b5ab3b31ee0ff6d093a2627707a1e221 (diff) |
tracing: use pointer error returns for __tracing_open
Impact: fix compile warning and clean up
When I first wrote __tracing_open, instead of passing the error
code via the ERR_PTR macros, I lazily used a separate parameter
to hold the return for errors.
When Frederic Weisbecker updated that function, he used the Linux
kernel ERR_PTR for the returns. This caused the parameter return
to possibly not be initialized on error. gcc correctly pointed this
out with a warning.
This patch converts the entire function to use the Linux kernel
ERR_PTR macro methods.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 6c89ec6cbd48..304e02ce39c4 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1684,23 +1684,20 @@ static struct seq_operations tracer_seq_ops = { | |||
1684 | }; | 1684 | }; |
1685 | 1685 | ||
1686 | static struct trace_iterator * | 1686 | static struct trace_iterator * |
1687 | __tracing_open(struct inode *inode, struct file *file, int *ret) | 1687 | __tracing_open(struct inode *inode, struct file *file) |
1688 | { | 1688 | { |
1689 | long cpu_file = (long) inode->i_private; | 1689 | long cpu_file = (long) inode->i_private; |
1690 | void *fail_ret = ERR_PTR(-ENOMEM); | ||
1690 | struct trace_iterator *iter; | 1691 | struct trace_iterator *iter; |
1691 | struct seq_file *m; | 1692 | struct seq_file *m; |
1692 | int cpu; | 1693 | int cpu, ret; |
1693 | 1694 | ||
1694 | if (tracing_disabled) { | 1695 | if (tracing_disabled) |
1695 | *ret = -ENODEV; | 1696 | return ERR_PTR(-ENODEV); |
1696 | return NULL; | ||
1697 | } | ||
1698 | 1697 | ||
1699 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); | 1698 | iter = kzalloc(sizeof(*iter), GFP_KERNEL); |
1700 | if (!iter) { | 1699 | if (!iter) |
1701 | *ret = -ENOMEM; | 1700 | return ERR_PTR(-ENOMEM); |
1702 | goto out; | ||
1703 | } | ||
1704 | 1701 | ||
1705 | /* | 1702 | /* |
1706 | * We make a copy of the current tracer to avoid concurrent | 1703 | * We make a copy of the current tracer to avoid concurrent |
@@ -1708,10 +1705,9 @@ __tracing_open(struct inode *inode, struct file *file, int *ret) | |||
1708 | */ | 1705 | */ |
1709 | mutex_lock(&trace_types_lock); | 1706 | mutex_lock(&trace_types_lock); |
1710 | iter->trace = kzalloc(sizeof(*iter->trace), GFP_KERNEL); | 1707 | iter->trace = kzalloc(sizeof(*iter->trace), GFP_KERNEL); |
1711 | if (!iter->trace) { | 1708 | if (!iter->trace) |
1712 | *ret = -ENOMEM; | ||
1713 | goto fail; | 1709 | goto fail; |
1714 | } | 1710 | |
1715 | if (current_trace) | 1711 | if (current_trace) |
1716 | *iter->trace = *current_trace; | 1712 | *iter->trace = *current_trace; |
1717 | 1713 | ||
@@ -1750,9 +1746,11 @@ __tracing_open(struct inode *inode, struct file *file, int *ret) | |||
1750 | } | 1746 | } |
1751 | 1747 | ||
1752 | /* TODO stop tracer */ | 1748 | /* TODO stop tracer */ |
1753 | *ret = seq_open(file, &tracer_seq_ops); | 1749 | ret = seq_open(file, &tracer_seq_ops); |
1754 | if (*ret) | 1750 | if (ret < 0) { |
1751 | fail_ret = ERR_PTR(ret); | ||
1755 | goto fail_buffer; | 1752 | goto fail_buffer; |
1753 | } | ||
1756 | 1754 | ||
1757 | m = file->private_data; | 1755 | m = file->private_data; |
1758 | m->private = iter; | 1756 | m->private = iter; |
@@ -1762,7 +1760,6 @@ __tracing_open(struct inode *inode, struct file *file, int *ret) | |||
1762 | 1760 | ||
1763 | mutex_unlock(&trace_types_lock); | 1761 | mutex_unlock(&trace_types_lock); |
1764 | 1762 | ||
1765 | out: | ||
1766 | return iter; | 1763 | return iter; |
1767 | 1764 | ||
1768 | fail_buffer: | 1765 | fail_buffer: |
@@ -1775,7 +1772,7 @@ __tracing_open(struct inode *inode, struct file *file, int *ret) | |||
1775 | kfree(iter->trace); | 1772 | kfree(iter->trace); |
1776 | kfree(iter); | 1773 | kfree(iter); |
1777 | 1774 | ||
1778 | return ERR_PTR(-ENOMEM); | 1775 | return fail_ret; |
1779 | } | 1776 | } |
1780 | 1777 | ||
1781 | int tracing_open_generic(struct inode *inode, struct file *filp) | 1778 | int tracing_open_generic(struct inode *inode, struct file *filp) |
@@ -1815,9 +1812,12 @@ static int tracing_release(struct inode *inode, struct file *file) | |||
1815 | 1812 | ||
1816 | static int tracing_open(struct inode *inode, struct file *file) | 1813 | static int tracing_open(struct inode *inode, struct file *file) |
1817 | { | 1814 | { |
1818 | int ret; | 1815 | struct trace_iterator *iter; |
1816 | int ret = 0; | ||
1819 | 1817 | ||
1820 | __tracing_open(inode, file, &ret); | 1818 | iter = __tracing_open(inode, file); |
1819 | if (IS_ERR(iter)) | ||
1820 | ret = PTR_ERR(iter); | ||
1821 | 1821 | ||
1822 | return ret; | 1822 | return ret; |
1823 | } | 1823 | } |
@@ -1825,11 +1825,13 @@ static int tracing_open(struct inode *inode, struct file *file) | |||
1825 | static int tracing_lt_open(struct inode *inode, struct file *file) | 1825 | static int tracing_lt_open(struct inode *inode, struct file *file) |
1826 | { | 1826 | { |
1827 | struct trace_iterator *iter; | 1827 | struct trace_iterator *iter; |
1828 | int ret; | 1828 | int ret = 0; |
1829 | 1829 | ||
1830 | iter = __tracing_open(inode, file, &ret); | 1830 | iter = __tracing_open(inode, file); |
1831 | 1831 | ||
1832 | if (!ret) | 1832 | if (IS_ERR(iter)) |
1833 | ret = PTR_ERR(iter); | ||
1834 | else | ||
1833 | iter->iter_flags |= TRACE_FILE_LAT_FMT; | 1835 | iter->iter_flags |= TRACE_FILE_LAT_FMT; |
1834 | 1836 | ||
1835 | return ret; | 1837 | return ret; |