Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-35600

Reconsider charset-specific snprintf’s vs. my_snprintf_ex

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      Charsets register charset-specific snprintf’s in struct my_charset_handler_st listings.
      I have identified these three:

      • my_snprintf_8bit used by most charsets
        Its code is equivalent to my_snprintf’s down to the assembly level. I discovered this from MDEV-21978 searches.
      • my_snprintf_mb2 and my_snprintf_utf32
        Their vsnprintf versions are separate copies of vsnprintf subsets that adds appropriate amounts of \0’s for their wide chars. They do not relate to each other nor my_snprintf.

      It may be possible to de-duplicate these functions into my_snprintf_ex, which already accepts a CHARSET_INFO * parameter.

      Note, the struct marks this member with ATTRIBUTE_FORMAT_FPTR(printf, …), but my_vsnprintf_ex (currently used by my_snprintf_8bit as mentioned) isn’t ATTRIBUTE_FORMAT_FPTR(printf, …)-compliant until MDEV-21978.
      This reminds us that. my_snprintf_8bit recognizes my_snprintf extensions while the others don’t, which is inconsistent, whether the intent is to permit or forbid those (e.g. if they’re user-accessible).

      We can't use vsprintf here as it's not guaranteed to return the length on all operating systems.

      The whole vsnprintf family is standardized to return the number of chars written since C99, our C standard. cppreference.com

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ParadoxV5 Jimmy Hú
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.