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

my_vsnprintf behaves not as in C standard

Details

    Description

      Some developers apparently don't like that now my_vsnprintf("%.*s") behaves not as in the C standard.

      So, we'll change it back and introduce %S to print the truncation indicator.

      All %s that print something to the end user have to be changed, for example, to %S. This includes all error messages and everything in the code too.

      Don't forget to update the documentation in the service header file.

      And we'll need some way to ensure that in the future all new printfs to the use also use %S.

      Attachments

        Issue Links

          Activity

            wlad Vladislav Vaintroub added a comment - - edited

            Please, do not use %S , this is confusing. %S It is there to print wide strings, i.e wchar_t *

            Even on Linux, and it is documented.

            wlad Vladislav Vaintroub added a comment - - edited Please, do not use %S , this is confusing. %S It is there to print wide strings, i.e wchar_t * Even on Linux, and it is documented.
            wlad Vladislav Vaintroub added a comment - - edited

            Maybe this can change, for example, to %sT , where T stands for truncated. And yes, the output will be different from whatever standard says, but it does not use either new unknown format specifiers, nor does it hijack the already known and documented ones, and it is still compatible with string, so you can use _attribute(format) on that.

            wlad Vladislav Vaintroub added a comment - - edited Maybe this can change, for example, to %sT , where T stands for truncated. And yes, the output will be different from whatever standard says, but it does not use either new unknown format specifiers, nor does it hijack the already known and documented ones, and it is still compatible with string, so you can use _ attribute (format) on that.

            yes, %sT, but that's after MDEV-21978. Depends on what's implemented first.

            serg Sergei Golubchik added a comment - yes, %sT , but that's after MDEV-21978 . Depends on what's implemented first.

            As far as I understand, the regression was introduced in MDEV-20604.

            marko Marko Mäkelä added a comment - As far as I understand, the regression was introduced in MDEV-20604 .
            marko Marko Mäkelä added a comment - - edited

            Sorry, I needed 2 after-merge fixes on 10.4. For the first one, my Windows build had failed without me noticing it, and that is why the %s→%T change was not reflected in the result file.

            marko Marko Mäkelä added a comment - - edited Sorry, I needed 2 after- merge fixes on 10.4. For the first one, my Windows build had failed without me noticing it, and that is why the %s→%T change was not reflected in the result file.

            People

              sanja Oleksandr Byelkin
              serg Sergei Golubchik
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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