[SECNET PATCH 13/14] util: priomsg: Provide and use priomsg_update_fixed
Ian Jackson
ijackson at chiark.greenend.org.uk
Sat Sep 21 17:07:58 BST 2019
We are going to want to reuse this.
No functional change.
Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
site.c | 5 ++---
util.c | 5 +++++
util.h | 3 +++
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/site.c b/site.c
index b210e8b..568b18d 100644
--- a/site.c
+++ b/site.c
@@ -2032,9 +2032,8 @@ static bool_t site_incoming(void *sst, struct buffer_if *buf,
return True;
}
- if (priomsg_update_p(whynot, comm_notify_whynot_general))
- truncmsg_add_string(&whynot->m,
- "not MSG1 or PROD; unknown dest index");
+ priomsg_update_fixed(whynot, comm_notify_whynot_general,
+ "not MSG1 or PROD; unknown dest index");
return False;
}
diff --git a/util.c b/util.c
index 45e2c93..b413c24 100644
--- a/util.c
+++ b/util.c
@@ -410,6 +410,11 @@ const char *priomsg_getmessage(const struct priomsg *pm, const char *defmsg)
return defmsg;
}
+bool_t priomsg_update_fixed(struct priomsg *pm, int prio, const char *m) {
+ if (!priomsg_update_p(pm, prio)) return False;
+ truncmsg_add_string(&pm->m, m);
+ return True;
+}
void buffer_new(struct buffer_if *buf, int32_t len)
{
diff --git a/util.h b/util.h
index 8971af7..19c99e1 100644
--- a/util.h
+++ b/util.h
@@ -81,6 +81,9 @@ const char *priomsg_getmessage(const struct priomsg *pm, const char *defmsg);
/* return value is null-terminated, valid until next call
* or until defmsg is no longer valid ZM */
+bool_t priomsg_update_fixed(struct priomsg *pm, int prio, const char *m);
+ /* convenience combination of _update_p and truncmsg_add_string */
+
/*
* void BUF_ADD_BYTES(append, struct buffer_if*, const void*, int32_t size);
* void BUF_ADD_BYTES(prepend, struct buffer_if*, const void*, int32_t size);
--
2.11.0
More information about the sgo-software-discuss
mailing list