summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-04-12 11:51:52 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-04-12 12:35:44 +0200
commit2a1a7910f9af6ec1ce0e5e6e8f271e3ea89b9d8b (patch)
treef142026abf0e49ac097ca03d19a3f3ff613b4dd8
parent69e6a4697039edf2e3f37c441bd4ee30c736620d (diff)
downloadsystemd-2a1a7910f9af6ec1ce0e5e6e8f271e3ea89b9d8b.tar.gz
man: add page for sd_device_{ref,unref,unrefp}
Gotta start somewhere.
-rw-r--r--man/rules/meson.build1
-rw-r--r--man/sd-device.xml3
-rw-r--r--man/sd_bus_new.xml12
-rw-r--r--man/sd_device_ref.xml83
4 files changed, 91 insertions, 8 deletions
diff --git a/man/rules/meson.build b/man/rules/meson.build
index 180b0abaaa..55376c0ecc 100644
--- a/man/rules/meson.build
+++ b/man/rules/meson.build
@@ -516,6 +516,7 @@ manpages = [
'sd_device_get_sysname',
'sd_device_get_sysnum'],
''],
+ ['sd_device_ref', '3', ['sd_device_unref', 'sd_device_unrefp'], ''],
['sd_event_add_child',
'3',
['sd_event_add_child_pidfd',
diff --git a/man/sd-device.xml b/man/sd-device.xml
index 3a86a28848..7af839b4bd 100644
--- a/man/sd-device.xml
+++ b/man/sd-device.xml
@@ -42,7 +42,8 @@
<filename>libudev.h</filename>.</para>
<para>See
- <literallayout><citerefentry><refentrytitle>sd_device_get_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+ <literallayout><citerefentry><refentrytitle>sd_device_get_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+<citerefentry><refentrytitle>sd_device_ref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</literallayout>
for more information about the functions available.</para>
</refsect1>
diff --git a/man/sd_bus_new.xml b/man/sd_bus_new.xml
index 355b34bad8..41964640b6 100644
--- a/man/sd_bus_new.xml
+++ b/man/sd_bus_new.xml
@@ -109,7 +109,7 @@
pointer to an <type>sd_bus</type> object. This call is useful in
conjunction with GCC's and LLVM's <ulink
url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
- Variable Attribute</ulink>. Note that this function is defined as
+ Variable Attribute</ulink>. Note that this function is defined as an
inline function. Use a declaration like the following, in order to
allocate a bus object that is freed automatically as the code
block is left:</para>
@@ -124,12 +124,10 @@
}</programlisting>
- <para><function>sd_bus_ref()</function> and <function>sd_bus_unref()</function>
- execute no operation if the passed in bus object address is
- <constant>NULL</constant>. <function>sd_bus_unrefp()</function> will first
- dereference its argument, which must not be <constant>NULL</constant>, and will
- execute no operation if <emphasis>that</emphasis> is <constant>NULL</constant>.
- </para>
+ <para><function>sd_bus_ref()</function> and <function>sd_bus_unref()</function> execute no operation if
+ the argument is <constant>NULL</constant>. <function>sd_bus_unrefp()</function> will first dereference
+ its argument, which must not be <constant>NULL</constant>, and will execute no operation if
+ <emphasis>that</emphasis> is <constant>NULL</constant>.</para>
<para><function>sd_bus_close_unref()</function> is similar to <function>sd_bus_unref()</function>, but
first executes
diff --git a/man/sd_device_ref.xml b/man/sd_device_ref.xml
new file mode 100644
index 0000000000..b7ed4d985c
--- /dev/null
+++ b/man/sd_device_ref.xml
@@ -0,0 +1,83 @@
+<?xml version='1.0'?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
+
+<refentry id="sd_device_ref" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <refentryinfo>
+ <title>sd_device_ref</title>
+ <productname>systemd</productname>
+ </refentryinfo>
+
+ <refmeta>
+ <refentrytitle>sd_device_ref</refentrytitle>
+ <manvolnum>3</manvolnum>
+ </refmeta>
+
+ <refnamediv>
+ <refname>sd_device_ref</refname>
+ <refname>sd_device_unref</refname>
+ <refname>sd_device_unrefp</refname>
+
+ <refpurpose>Create or destroy references to a device object</refpurpose>
+ </refnamediv>
+
+ <refsynopsisdiv>
+ <funcsynopsis>
+ <funcsynopsisinfo>#include &lt;systemd/sd-device.h&gt;</funcsynopsisinfo>
+
+ <funcprototype>
+ <funcdef>sd_device* <function>sd_device_ref</function></funcdef>
+ <paramdef>sd_device *<parameter>device</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>sd_device* <function>sd_device_unref</function></funcdef>
+ <paramdef>sd_device *<parameter>device</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>void <function>sd_device_unrefp</function></funcdef>
+ <paramdef>sd_device **<parameter>device</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+
+ <para><function>sd_device_ref()</function> increases the reference counter of
+ <parameter>device</parameter> by one.</para>
+
+ <para><function>sd_device_unref()</function> decreases the reference counter of
+ <parameter>device</parameter> by one. Once the reference count has dropped to zero,
+ <parameter>device</parameter> is destroyed and cannot be used anymore, so further calls to
+ <function>sd_device_ref()</function> or <function>sd_device_unref()</function> are illegal.</para>
+
+ <para><function>sd_device_unrefp()</function> is similar to <function>sd_device_unref()</function> but
+ takes a pointer to a pointer to an <type>sd_device</type> object. This call is useful in conjunction with
+ GCC's and LLVM's <ulink url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
+ Variable Attribute</ulink>. Note that this function is defined as an inline function. Use a declaration
+ like the following, in order to allocate a device object that is freed automatically as the code block is
+ left:</para>
+
+ <programlisting>{
+ __attribute__((cleanup(sd_device_unrefp))) sd_device *device = NULL;
+ int r;
+ …
+ r = sd_device_new_from_syspath(&amp;device, "…");
+ if (r &lt; 0)
+ fprintf(stderr, "Failed to allocate device: %s\n", strerror(-r));
+ …
+}</programlisting>
+
+ <para><function>sd_device_ref()</function> and <function>sd_device_unref()</function> execute no
+ operation if the argument is <constant>NULL</constant>. <function>sd_device_unrefp()</function> will
+ first dereference its argument, which must not be <constant>NULL</constant>, and will execute no
+ operation if <emphasis>that</emphasis> is <constant>NULL</constant>.</para>
+ </refsynopsisdiv>
+
+ <refsect1>
+ <title>Return Value</title>
+
+ <para><function>sd_device_ref()</function> always returns the argument, and
+ <function>sd_device_unref()</function> always returns <constant>NULL</constant>.
+ </para>
+ </refsect1>
+</refentry>