Skip to content

Fix clang string-plus-int warning - #3729

Closed
rikardfalkeborn wants to merge 1 commit into
curl:masterfrom
rikardfalkeborn:string-plus-int-warning-clang8
Closed

Fix clang string-plus-int warning#3729
rikardfalkeborn wants to merge 1 commit into
curl:masterfrom
rikardfalkeborn:string-plus-int-warning-clang8

Conversation

@rikardfalkeborn

Copy link
Copy Markdown
Contributor

Clang 8 warns about adding a string to an int does not append to the
string. Indeed it doesn't, but that was not the intention either. Use
array indexing as suggested to silence the warning. There should be no
functional changes.

The full warning message was:

smtp.c:1221:29: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
      eob = strdup(SMTP_EOB + 2);
            ~~~~~~~~~~~~~~~~^~~~
../lib/memdebug.h:88:37: note: expanded from macro 'strdup'
#define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
                                    ^~~
smtp.c:1221:29: note: use array indexing to silence this warning
      eob = strdup(SMTP_EOB + 2);
                            ^
                   &        [
../lib/memdebug.h:88:37: note: expanded from macro 'strdup'

Clang 8 warns about adding a string to an int does not append to the
string. Indeed it doesn't, but that was not the intention either. Use
array indexing as suggested to silence the warning. There should be no
functional changes.

The full warning message was:

    smtp.c:1221:29: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
          eob = strdup(SMTP_EOB + 2);
                ~~~~~~~~~~~~~~~~^~~~
    ../lib/memdebug.h:88:37: note: expanded from macro 'strdup'
    #define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
                                        ^~~
    smtp.c:1221:29: note: use array indexing to silence this warning
          eob = strdup(SMTP_EOB + 2);
                                ^
                       &        [
    ../lib/memdebug.h:88:37: note: expanded from macro 'strdup'
@jay jay closed this in f5a7747 Apr 5, 2019
@jay

jay commented Apr 5, 2019

Copy link
Copy Markdown
Member

Thanks

@rikardfalkeborn
rikardfalkeborn deleted the string-plus-int-warning-clang8 branch April 5, 2019 04:20
@lock lock Bot locked as resolved and limited conversation to collaborators Jul 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants