summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-12-14 04:55:47 +0100
committerdefault <nobody@localhost>2022-12-14 04:55:47 +0100
commit645e7ec43e24600c8a3ecab3e43b07a6dbc91eb4 (patch)
treec964f5950b6519d37d932fb059972c1b5fd56ee0
parentf5086fecd74310ad9be959a308bd15046cc3d4f1 (diff)
Some code reordering to placate scan-build's wrath.
-rw-r--r--activitypub.c20
-rw-r--r--format.c3
-rw-r--r--snac.c16
3 files changed, 25 insertions, 14 deletions
diff --git a/activitypub.c b/activitypub.c
index 88febbf..e003cfc 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -264,7 +264,9 @@ void process_tags(const char *content, d_char **n_content, d_char **tag)
char *p, *v;
int n = 0;
- p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)");
+ split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)");
+
+ p = split;
while (xs_list_iter(&p, &v)) {
if ((n & 0x1)) {
if (*v == '@') {
@@ -320,18 +322,24 @@ d_char *msg_base(snac *snac, char *type, char *id, char *actor, char *date, char
xs *published = NULL;
/* generated values */
- if (date && strcmp(date, "@now") == 0)
- date = published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ");
+ if (date && strcmp(date, "@now") == 0) {
+ published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ");
+ date = published;
+ }
if (id != NULL) {
if (strcmp(id, "@dummy") == 0) {
xs *ntid = tid(0);
- id = did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type);
+ did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type);
+
+ id = did;
}
else
if (strcmp(id, "@object") == 0) {
- if (object != NULL)
- id = did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
+ if (object != NULL) {
+ did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
+ id = did;
+ }
else
id = NULL;
}
diff --git a/format.c b/format.c
index d149def..7ded83c 100644
--- a/format.c
+++ b/format.c
@@ -98,8 +98,9 @@ d_char *not_really_markdown(const char *content)
char *p, *v;
/* work by lines */
- p = list = xs_split(content, "\n");
+ list = xs_split(content, "\n");
+ p = list;
while (xs_list_iter(&p, &v)) {
xs *ss = NULL;
diff --git a/snac.c b/snac.c
index 903713b..2a54447 100644
--- a/snac.c
+++ b/snac.c
@@ -74,17 +74,17 @@ int validate_uid(const char *uid)
void srv_debug(int level, d_char *str)
/* logs a debug message */
{
- xs *msg = str;
-
- if (xs_str_in(msg, srv_basedir) != -1) {
+ if (xs_str_in(str, srv_basedir) != -1) {
/* replace basedir with ~ */
- msg = xs_replace_i(msg, srv_basedir, "~");
+ str = xs_replace_i(str, srv_basedir, "~");
}
if (dbglevel >= level) {
xs *tm = xs_str_localtime(0, "%H:%M:%S");
- fprintf(stderr, "%s %s\n", tm, msg);
+ fprintf(stderr, "%s %s\n", tm, str);
}
+
+ xs_free(str);
}
@@ -110,8 +110,10 @@ d_char *hash_password(const char *uid, const char *passwd, const char *nonce)
xs *combi;
xs *hash;
- if (nonce == NULL)
- nonce = d_nonce = xs_fmt("%08x", random());
+ if (nonce == NULL) {
+ d_nonce = xs_fmt("%08x", random());
+ nonce = d_nonce;
+ }
combi = xs_fmt("%s:%s:%s", nonce, uid, passwd);
hash = xs_sha1_hex(combi, strlen(combi));