aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-08-08 09:28:40 +0200
committerPřemysl Eric Janouch <p@janouch.name>2024-08-08 14:39:28 +0200
commite83cfa3c15810dc1df2468bc003f3014002a12b3 (patch)
treecc30e324d90ef181028a7f069468582a5a02f24f
parent29c89942ce6a266fd30a218abb022f55805ec01c (diff)
downloaddesktop-tools-e83cfa3c15810dc1df2468bc003f3014002a12b3.tar.gz
desktop-tools-e83cfa3c15810dc1df2468bc003f3014002a12b3.tar.xz
desktop-tools-e83cfa3c15810dc1df2468bc003f3014002a12b3.zip
Fix calloc argument order, add some consts
-rw-r--r--fancontrol-ng.c10
-rw-r--r--paswitch.c2
2 files changed, 6 insertions, 6 deletions
diff --git a/fancontrol-ng.c b/fancontrol-ng.c
index ec06dfb..e87dce1 100644
--- a/fancontrol-ng.c
+++ b/fancontrol-ng.c
@@ -124,7 +124,7 @@ config_validate_nonnegative (const struct config_item *item, struct error **e)
return error_set (e, "must be non-negative");
}
-static struct config_schema g_config_device[] =
+static const struct config_schema g_config_device[] =
{
{ .name = "name",
.comment = "Device identifier",
@@ -137,7 +137,7 @@ static struct config_schema g_config_device[] =
{}
};
-static struct config_schema g_config_pwm[] =
+static const struct config_schema g_config_pwm[] =
{
{ .name = "temp",
.comment = "Path to temperature sensor output",
@@ -415,7 +415,7 @@ device_create (struct app_context *ctx, const char *path,
// There is no room for errors in the configuration, everything must be valid.
// Thus the reset to defaults on invalid values is effectively disabled here.
static bool
-apply_schema (struct config_schema *schema, struct config_item *object,
+apply_schema (const struct config_schema *schema, struct config_item *object,
struct error **e)
{
struct error *warning = NULL, *error = NULL;
@@ -445,7 +445,7 @@ static bool
check_device_configuration (struct config_item *subtree, struct error **e)
{
// Check regular fields in the device object
- for (struct config_schema *s = g_config_device; s->name; s++)
+ for (const struct config_schema *s = g_config_device; s->name; s++)
if (!apply_schema (s, subtree, e))
return false;
@@ -465,7 +465,7 @@ check_device_configuration (struct config_item *subtree, struct error **e)
while ((pwm = str_map_iter_next (&iter)))
{
const char *subpath = iter.link->key;
- for (struct config_schema *s = g_config_pwm; s->name; s++)
+ for (const struct config_schema *s = g_config_pwm; s->name; s++)
if (!apply_schema (s, pwm, &error))
{
error_set (e, "PWM `%s': %s", subpath, error->message);
diff --git a/paswitch.c b/paswitch.c
index 66cec1d..3d329f4 100644
--- a/paswitch.c
+++ b/paswitch.c
@@ -290,7 +290,7 @@ on_sink_info (pa_context *context, const pa_sink_info *info, int eol,
sink->ports_len++;
struct port *port = sink->ports =
- xcalloc (sizeof *sink->ports, sink->ports_len);
+ xcalloc (sink->ports_len, sizeof *sink->ports);
for (struct pa_sink_port_info **iter = info->ports; *iter; iter++)
{
port->name = xstrdup ((*iter)->name);