mirror of
https://github.com/systemd/systemd.git
synced 2025-01-30 01:47:42 +03:00
Merge pull request #21870 from keszybz/cleanup-and-comments
Use _cleanup_ and adjust comments
This commit is contained in:
commit
a5016a0ace
@ -24,15 +24,15 @@ typedef struct StaticDestructor {
|
|||||||
typeof(variable) *q = p; \
|
typeof(variable) *q = p; \
|
||||||
func(q); \
|
func(q); \
|
||||||
} \
|
} \
|
||||||
/* Older compilers don't know retain attribute. */ \
|
/* Older compilers don't know "retain" attribute. */ \
|
||||||
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
|
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
|
||||||
/* The actual destructor structure we place in a special section to find it */ \
|
/* The actual destructor structure we place in a special section to find it. */ \
|
||||||
_section_("SYSTEMD_STATIC_DESTRUCT") \
|
_section_("SYSTEMD_STATIC_DESTRUCT") \
|
||||||
/* We pick pointer alignment, since that is apparently what gcc does for static variables */ \
|
/* Use pointer alignment, since that is apparently what gcc does for static variables. */ \
|
||||||
_alignptr_ \
|
_alignptr_ \
|
||||||
/* Make sure this is not dropped from the image because not explicitly referenced */ \
|
/* Make sure this is not dropped from the image despite not being explicitly referenced. */ \
|
||||||
_used_ \
|
_used_ \
|
||||||
/* Prevent linker from garbage collection. */ \
|
/* Prevent garbage collection by the linker. */ \
|
||||||
_retain_ \
|
_retain_ \
|
||||||
/* Make sure that AddressSanitizer doesn't pad this variable: we want everything in this section
|
/* Make sure that AddressSanitizer doesn't pad this variable: we want everything in this section
|
||||||
* packed next to each other so that we can enumerate it. */ \
|
* packed next to each other so that we can enumerate it. */ \
|
||||||
|
@ -191,7 +191,7 @@ static bool valid_deployment(const char *deployment) {
|
|||||||
|
|
||||||
static const char* fallback_chassis(void) {
|
static const char* fallback_chassis(void) {
|
||||||
const char *chassis;
|
const char *chassis;
|
||||||
char *type;
|
_cleanup_free_ char *type = NULL;
|
||||||
unsigned t;
|
unsigned t;
|
||||||
int v, r;
|
int v, r;
|
||||||
|
|
||||||
@ -210,18 +210,17 @@ static const char* fallback_chassis(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = safe_atou(type, &t);
|
r = safe_atou(type, &t);
|
||||||
free(type);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_debug_errno(r, "Failed to parse DMI chassis type, ignoring: %m");
|
log_debug_errno(r, "Failed to parse DMI chassis type \"%s\", ignoring: %m", type);
|
||||||
goto try_acpi;
|
goto try_acpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We only list the really obvious cases here. The DMI data is unreliable enough, so let's not do any
|
/* We only list the really obvious cases here. The DMI data is unreliable enough, so let's not do any
|
||||||
additional guesswork on top of that.
|
* additional guesswork on top of that.
|
||||||
|
*
|
||||||
See the SMBIOS Specification 3.0 section 7.4.1 for details about the values listed here:
|
* See the SMBIOS Specification 3.0 section 7.4.1 for details about the values listed here:
|
||||||
|
*
|
||||||
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
|
* https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
@ -259,6 +258,7 @@ static const char* fallback_chassis(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try_acpi:
|
try_acpi:
|
||||||
|
type = mfree(type);
|
||||||
r = read_one_line_file("/sys/firmware/acpi/pm_profile", &type);
|
r = read_one_line_file("/sys/firmware/acpi/pm_profile", &type);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_debug_errno(r, "Failed read ACPI PM profile, ignoring: %m");
|
log_debug_errno(r, "Failed read ACPI PM profile, ignoring: %m");
|
||||||
@ -266,9 +266,8 @@ try_acpi:
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = safe_atou(type, &t);
|
r = safe_atou(type, &t);
|
||||||
free(type);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_debug_errno(r, "Failed parse ACPI PM profile, ignoring: %m");
|
log_debug_errno(r, "Failed parse ACPI PM profile \"%s\", ignoring: %m", type);
|
||||||
goto try_devicetree;
|
goto try_devicetree;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,6 +301,7 @@ try_acpi:
|
|||||||
}
|
}
|
||||||
|
|
||||||
try_devicetree:
|
try_devicetree:
|
||||||
|
type = mfree(type);
|
||||||
r = read_one_line_file("/proc/device-tree/chassis-type", &type);
|
r = read_one_line_file("/proc/device-tree/chassis-type", &type);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_debug_errno(r, "Failed to read device-tree chassis type, ignoring: %m");
|
log_debug_errno(r, "Failed to read device-tree chassis type, ignoring: %m");
|
||||||
@ -314,10 +314,7 @@ try_devicetree:
|
|||||||
* https://github.com/devicetree-org/devicetree-specification/blob/master/source/chapter3-devicenodes.rst */
|
* https://github.com/devicetree-org/devicetree-specification/blob/master/source/chapter3-devicenodes.rst */
|
||||||
chassis = valid_chassis(type);
|
chassis = valid_chassis(type);
|
||||||
if (!chassis)
|
if (!chassis)
|
||||||
log_debug("Invalid device-tree chassis type '%s', ignoring.", type);
|
log_debug("Invalid device-tree chassis type \"%s\", ignoring.", type);
|
||||||
|
|
||||||
free(type);
|
|
||||||
|
|
||||||
return chassis;
|
return chassis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* These functions are split out of tmpfile-util.h (and not for example just flags to the functions they wrap) in order
|
/* These functions are split out of tmpfile-util.h (and not for example just flags to the functions they
|
||||||
* to optimize linking: This way, -lselinux is needed only for the callers of these functions that need selinux, but
|
* wrap) in order to optimize linking: this way, -lselinux is needed only for the callers of these functions
|
||||||
* not for all */
|
* that need selinux, but not for all. */
|
||||||
|
|
||||||
int fopen_temporary_label(const char *target, const char *path, FILE **f, char **temp_path);
|
int fopen_temporary_label(const char *target, const char *path, FILE **f, char **temp_path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user