Commit a378ba49 authored by Peter Eisentraut's avatar Peter Eisentraut

Add pg_nodiscard decorations to some functions

Especially for the list API such as lappend() forgetting to assign the
return value is a common problem.
Reviewed-by: default avatarMichael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/e3753562-99cd-b65f-5aca-687dfd1ec2fc@2ndquadrant.com
parent c617aea6
...@@ -521,36 +521,36 @@ extern List *list_make3_impl(NodeTag t, ListCell datum1, ListCell datum2, ...@@ -521,36 +521,36 @@ extern List *list_make3_impl(NodeTag t, ListCell datum1, ListCell datum2,
extern List *list_make4_impl(NodeTag t, ListCell datum1, ListCell datum2, extern List *list_make4_impl(NodeTag t, ListCell datum1, ListCell datum2,
ListCell datum3, ListCell datum4); ListCell datum3, ListCell datum4);
extern List *lappend(List *list, void *datum); extern pg_nodiscard List *lappend(List *list, void *datum);
extern List *lappend_int(List *list, int datum); extern pg_nodiscard List *lappend_int(List *list, int datum);
extern List *lappend_oid(List *list, Oid datum); extern pg_nodiscard List *lappend_oid(List *list, Oid datum);
extern List *list_insert_nth(List *list, int pos, void *datum); extern pg_nodiscard List *list_insert_nth(List *list, int pos, void *datum);
extern List *list_insert_nth_int(List *list, int pos, int datum); extern pg_nodiscard List *list_insert_nth_int(List *list, int pos, int datum);
extern List *list_insert_nth_oid(List *list, int pos, Oid datum); extern pg_nodiscard List *list_insert_nth_oid(List *list, int pos, Oid datum);
extern List *lcons(void *datum, List *list); extern pg_nodiscard List *lcons(void *datum, List *list);
extern List *lcons_int(int datum, List *list); extern pg_nodiscard List *lcons_int(int datum, List *list);
extern List *lcons_oid(Oid datum, List *list); extern pg_nodiscard List *lcons_oid(Oid datum, List *list);
extern List *list_concat(List *list1, const List *list2); extern pg_nodiscard List *list_concat(List *list1, const List *list2);
extern List *list_concat_copy(const List *list1, const List *list2); extern pg_nodiscard List *list_concat_copy(const List *list1, const List *list2);
extern List *list_truncate(List *list, int new_size); extern pg_nodiscard List *list_truncate(List *list, int new_size);
extern bool list_member(const List *list, const void *datum); extern bool list_member(const List *list, const void *datum);
extern bool list_member_ptr(const List *list, const void *datum); extern bool list_member_ptr(const List *list, const void *datum);
extern bool list_member_int(const List *list, int datum); extern bool list_member_int(const List *list, int datum);
extern bool list_member_oid(const List *list, Oid datum); extern bool list_member_oid(const List *list, Oid datum);
extern List *list_delete(List *list, void *datum); extern pg_nodiscard List *list_delete(List *list, void *datum);
extern List *list_delete_ptr(List *list, void *datum); extern pg_nodiscard List *list_delete_ptr(List *list, void *datum);
extern List *list_delete_int(List *list, int datum); extern pg_nodiscard List *list_delete_int(List *list, int datum);
extern List *list_delete_oid(List *list, Oid datum); extern pg_nodiscard List *list_delete_oid(List *list, Oid datum);
extern List *list_delete_first(List *list); extern pg_nodiscard List *list_delete_first(List *list);
extern List *list_delete_last(List *list); extern pg_nodiscard List *list_delete_last(List *list);
extern List *list_delete_nth_cell(List *list, int n); extern pg_nodiscard List *list_delete_nth_cell(List *list, int n);
extern List *list_delete_cell(List *list, ListCell *cell); extern pg_nodiscard List *list_delete_cell(List *list, ListCell *cell);
extern List *list_union(const List *list1, const List *list2); extern List *list_union(const List *list1, const List *list2);
extern List *list_union_ptr(const List *list1, const List *list2); extern List *list_union_ptr(const List *list1, const List *list2);
...@@ -567,24 +567,24 @@ extern List *list_difference_ptr(const List *list1, const List *list2); ...@@ -567,24 +567,24 @@ extern List *list_difference_ptr(const List *list1, const List *list2);
extern List *list_difference_int(const List *list1, const List *list2); extern List *list_difference_int(const List *list1, const List *list2);
extern List *list_difference_oid(const List *list1, const List *list2); extern List *list_difference_oid(const List *list1, const List *list2);
extern List *list_append_unique(List *list, void *datum); extern pg_nodiscard List *list_append_unique(List *list, void *datum);
extern List *list_append_unique_ptr(List *list, void *datum); extern pg_nodiscard List *list_append_unique_ptr(List *list, void *datum);
extern List *list_append_unique_int(List *list, int datum); extern pg_nodiscard List *list_append_unique_int(List *list, int datum);
extern List *list_append_unique_oid(List *list, Oid datum); extern pg_nodiscard List *list_append_unique_oid(List *list, Oid datum);
extern List *list_concat_unique(List *list1, const List *list2); extern pg_nodiscard List *list_concat_unique(List *list1, const List *list2);
extern List *list_concat_unique_ptr(List *list1, const List *list2); extern pg_nodiscard List *list_concat_unique_ptr(List *list1, const List *list2);
extern List *list_concat_unique_int(List *list1, const List *list2); extern pg_nodiscard List *list_concat_unique_int(List *list1, const List *list2);
extern List *list_concat_unique_oid(List *list1, const List *list2); extern pg_nodiscard List *list_concat_unique_oid(List *list1, const List *list2);
extern void list_deduplicate_oid(List *list); extern void list_deduplicate_oid(List *list);
extern void list_free(List *list); extern void list_free(List *list);
extern void list_free_deep(List *list); extern void list_free_deep(List *list);
extern List *list_copy(const List *list); extern pg_nodiscard List *list_copy(const List *list);
extern List *list_copy_tail(const List *list, int nskip); extern pg_nodiscard List *list_copy_tail(const List *list, int nskip);
extern List *list_copy_deep(const List *oldlist); extern pg_nodiscard List *list_copy_deep(const List *oldlist);
typedef int (*list_sort_comparator) (const ListCell *a, const ListCell *b); typedef int (*list_sort_comparator) (const ListCell *a, const ListCell *b);
extern void list_sort(List *list, list_sort_comparator cmp); extern void list_sort(List *list, list_sort_comparator cmp);
......
...@@ -77,7 +77,7 @@ extern void *MemoryContextAllocExtended(MemoryContext context, ...@@ -77,7 +77,7 @@ extern void *MemoryContextAllocExtended(MemoryContext context,
extern void *palloc(Size size); extern void *palloc(Size size);
extern void *palloc0(Size size); extern void *palloc0(Size size);
extern void *palloc_extended(Size size, int flags); extern void *palloc_extended(Size size, int flags);
extern void *repalloc(void *pointer, Size size); extern pg_nodiscard void *repalloc(void *pointer, Size size);
extern void pfree(void *pointer); extern void pfree(void *pointer);
/* /*
...@@ -95,7 +95,7 @@ extern void pfree(void *pointer); ...@@ -95,7 +95,7 @@ extern void pfree(void *pointer);
/* Higher-limit allocators. */ /* Higher-limit allocators. */
extern void *MemoryContextAllocHuge(MemoryContext context, Size size); extern void *MemoryContextAllocHuge(MemoryContext context, Size size);
extern void *repalloc_huge(void *pointer, Size size); extern pg_nodiscard void *repalloc_huge(void *pointer, Size size);
/* /*
* Although this header file is nominally backend-only, certain frontend * Although this header file is nominally backend-only, certain frontend
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment