[OpenSIPS-Devel] [OpenSIPS/opensips] 5c7282: Add const_str() macro, a better way to generate po...

Maksym Sobolyev noreply at github.com
Thu Jan 28 17:15:39 EST 2021


  Branch: refs/heads/master
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 5c7282447372a44c89773f8ecf1e0b1db0a8352e
      https://github.com/OpenSIPS/opensips/commit/5c7282447372a44c89773f8ecf1e0b1db0a8352e
  Author: Maksym Sobolyev <sobomax at sippysoft.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    M str.h

  Log Message:
  -----------
  Add const_str() macro, a better way to generate point-of-use
string literal of type const str_const * to be used in cases like:

    str_strcmp(in, _str("header"))

The problem with the _str() usage in this scenario among many
is that it updates the static pointer burried somewhere in
application guts with length and location of the buffer containing
its argument (e.g. "header" in this case) each time the
operation is performed and that extra work cannot be optimized
away. I have confirmed it with the Compiler Explorer, it costs
us two memory writes each time str_strcmp() is invoked.
Which not only isn't secure but also should have at least some
negative performance effect.

Use of:

     str_strcmp(in, const_str("header"))

in this scenario will not only be free of that effect, but also
pointer provided by the const_str can generally be passed
along and saved as needed, it will always be valid as long as
the application runs.


  Commit: 18b46da602f2305b8718d50499b1bced6280030d
      https://github.com/OpenSIPS/opensips/commit/18b46da602f2305b8718d50499b1bced6280030d
  Author: Maksym Sobolyev <sobomax at sippysoft.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    M modules/auth/challenge.c
    M modules/b2b_logic/b2b_logic.c
    M modules/b2b_logic/b2bl_db.c
    M modules/b2b_logic/entity_storage.c
    M modules/b2b_logic/logic.c
    M modules/b2b_logic_xml/b2b_logic.c
    M modules/presence_dfks/presence_dfks.c
    M modules/stir_shaken/stir_shaken.c
    M modules/topology_hiding/topology_hiding.c

  Log Message:
  -----------
  Use const_str(), not _str() to generate point-of-use string literal
for calling the str_strcmp().


  Commit: cb152009054cdb06e3a35b474ee482c8e8bbae42
      https://github.com/OpenSIPS/opensips/commit/cb152009054cdb06e3a35b474ee482c8e8bbae42
  Author: Maksym Sobolyev <sobomax at sippysoft.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    M modules/presence_dfks/Makefile

  Log Message:
  -----------
  Remove unnecessary and harmful CROSS_COMPILE conditinal here.


  Commit: 609f22f6af3b5bc6f0bcfd1e85999de12c0cc2db
      https://github.com/OpenSIPS/opensips/commit/609f22f6af3b5bc6f0bcfd1e85999de12c0cc2db
  Author: Maksym Sobolyev <sobomax at sippysoft.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    R modules/mathops/tinyexpr - LICENSE.md
    A modules/mathops/tinyexpr-LICENSE.md

  Log Message:
  -----------
  Having space in file name is bit rude.


  Commit: 4ac1ad5a17b9b44501ddae683ffbf50a5aed61f0
      https://github.com/OpenSIPS/opensips/commit/4ac1ad5a17b9b44501ddae683ffbf50a5aed61f0
  Author: Maksym Sobolyev <sobomax at sippysoft.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    M Makefile.defs

  Log Message:
  -----------
  Fix generics test: void main() -> int main().


Compare: https://github.com/OpenSIPS/opensips/compare/a14c74f605c4...4ac1ad5a17b9



More information about the Devel mailing list