]> git.ipfire.org Git - thirdparty/ulogd2.git/commit
db: improve formatting of insert statement
authorJeremy Sowden <jeremy@azazel.net>
Tue, 30 Nov 2021 10:55:52 +0000 (10:55 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 3 Jan 2022 15:33:31 +0000 (16:33 +0100)
commit2bb3c1b74c40fdd4de709ffc469619d5e404db73
tree6373aeb5694baf13adfacf294e3a21f12fb45408
parentdd80349ac72244049ab8f57023ab5d362e3843f1
db: improve formatting of insert statement

`sql_createstmt` contains a variable `stmt_val` which points to the end
of the SQL already written, where the next chunk should be appended.
Currently, this is assigned after every write:

  sprintf(stmt_val, ...);
  stmt_val = mi->stmt + strlen(mi->stmt);

However, since `sprintf` returns the number of bytes written, increment
`stmt_val` by the return-value of `sprintf` in order to avoid the
repeated `strlen` calls.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
util/db.c