History

XArray: Mark xa_insert and xa_reserve as must_check

If the user doesn't care about the return value from xa_insert(), then they should be using xa_store() instead. The point of xa_reserve() is to get the return value early before taking another lock, so this should also be __must_check.

Matthew Wilcox committed 7 years ago

Commit f818b821 parent 2fa044e2 files · +17 −16Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/xarray.h+12−11
@@ -497,12 +497,13 @@ void *__xa_erase(struct xarray *, unsigned long index); · 496 unmodified lines
497void *__xa_store(struct xarray *, unsigned long index, void *entry, gfp_t);497void *__xa_store(struct xarray *, unsigned long index, void *entry, gfp_t);
498void *__xa_cmpxchg(struct xarray *, unsigned long index, void *old,498void *__xa_cmpxchg(struct xarray *, unsigned long index, void *old,
499 void *entry, gfp_t);499 void *entry, gfp_t);
500int __xa_insert(struct xarray *, unsigned long index, void *entry, gfp_t);500int __must_check __xa_insert(struct xarray *, unsigned long index,
501 void *entry, gfp_t);
501int __must_check __xa_alloc(struct xarray *, u32 *id, void *entry,502int __must_check __xa_alloc(struct xarray *, u32 *id, void *entry,
502 struct xa_limit, gfp_t);503 struct xa_limit, gfp_t);
503int __must_check __xa_alloc_cyclic(struct xarray *, u32 *id, void *entry,504int __must_check __xa_alloc_cyclic(struct xarray *, u32 *id, void *entry,
504 struct xa_limit, u32 *next, gfp_t);505 struct xa_limit, u32 *next, gfp_t);
505int __xa_reserve(struct xarray *, unsigned long index, gfp_t);506int __must_check __xa_reserve(struct xarray *, unsigned long index, gfp_t);
506void __xa_set_mark(struct xarray *, unsigned long index, xa_mark_t);507void __xa_set_mark(struct xarray *, unsigned long index, xa_mark_t);
507void __xa_clear_mark(struct xarray *, unsigned long index, xa_mark_t);508void __xa_clear_mark(struct xarray *, unsigned long index, xa_mark_t);
508 509
@@ -704,8 +705,8 @@ static inline void *xa_cmpxchg_irq(struct xarray *xa, unsigned long index, · 195 unmodified lines
704 * Return: 0 if the store succeeded. -EBUSY if another entry was present.705 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
705 * -ENOMEM if memory could not be allocated.706 * -ENOMEM if memory could not be allocated.
706 */707 */
707static inline int xa_insert(struct xarray *xa, unsigned long index,708static inline int __must_check xa_insert(struct xarray *xa,
708 void *entry, gfp_t gfp)709 unsigned long index, void *entry, gfp_t gfp)
709{710{
710 int err;711 int err;
711 712
@@ -733,8 +734,8 @@ static inline int xa_insert(struct xarray *xa, unsigned long index, · 21 unmodified lines
733 * Return: 0 if the store succeeded. -EBUSY if another entry was present.734 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
734 * -ENOMEM if memory could not be allocated.735 * -ENOMEM if memory could not be allocated.
735 */736 */
736static inline int xa_insert_bh(struct xarray *xa, unsigned long index,737static inline int __must_check xa_insert_bh(struct xarray *xa,
737 void *entry, gfp_t gfp)738 unsigned long index, void *entry, gfp_t gfp)
738{739{
739 int err;740 int err;
740 741
@@ -762,8 +763,8 @@ static inline int xa_insert_bh(struct xarray *xa, unsigned long index, · 21 unmodified lines
762 * Return: 0 if the store succeeded. -EBUSY if another entry was present.763 * Return: 0 if the store succeeded. -EBUSY if another entry was present.
763 * -ENOMEM if memory could not be allocated.764 * -ENOMEM if memory could not be allocated.
764 */765 */
765static inline int xa_insert_irq(struct xarray *xa, unsigned long index,766static inline int __must_check xa_insert_irq(struct xarray *xa,
766 void *entry, gfp_t gfp)767 unsigned long index, void *entry, gfp_t gfp)
767{768{
768 int err;769 int err;
769 770
@@ -978,7 +979,7 @@ static inline int xa_alloc_cyclic_irq(struct xarray *xa, u32 *id, void *entry, · 208 unmodified lines
978 * May sleep if the @gfp flags permit.979 * May sleep if the @gfp flags permit.
979 * Return: 0 if the reservation succeeded or -ENOMEM if it failed.980 * Return: 0 if the reservation succeeded or -ENOMEM if it failed.
980 */981 */
981static inline982static inline __must_check
982int xa_reserve(struct xarray *xa, unsigned long index, gfp_t gfp)983int xa_reserve(struct xarray *xa, unsigned long index, gfp_t gfp)
983{984{
984 int ret;985 int ret;
@@ -1002,7 +1003,7 @@ int xa_reserve(struct xarray *xa, unsigned long index, gfp_t gfp) · 17 unmodified lines
1002 * disabling softirqs.1003 * disabling softirqs.
1003 * Return: 0 if the reservation succeeded or -ENOMEM if it failed.1004 * Return: 0 if the reservation succeeded or -ENOMEM if it failed.
1004 */1005 */
1005static inline1006static inline __must_check
1006int xa_reserve_bh(struct xarray *xa, unsigned long index, gfp_t gfp)1007int xa_reserve_bh(struct xarray *xa, unsigned long index, gfp_t gfp)
1007{1008{
1008 int ret;1009 int ret;
@@ -1026,7 +1027,7 @@ int xa_reserve_bh(struct xarray *xa, unsigned long index, gfp_t gfp) · 17 unmodified lines
1026 * disabling interrupts.1027 * disabling interrupts.
1027 * Return: 0 if the reservation succeeded or -ENOMEM if it failed.1028 * Return: 0 if the reservation succeeded or -ENOMEM if it failed.
1028 */1029 */
1029static inline1030static inline __must_check
1030int xa_reserve_irq(struct xarray *xa, unsigned long index, gfp_t gfp)1031int xa_reserve_irq(struct xarray *xa, unsigned long index, gfp_t gfp)
1031{1032{
1032 int ret;1033 int ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t