~yadi/squid/warnings

« back to all changes in this revision

Viewing changes to src/SBuf.h

  • Committer: Amos Jeffries
  • Date: 2015-02-06 21:23:19 UTC
  • Revision ID: squid3@treenet.co.nz-20150206212319-yvb5ujosl4l04m92
Fix for Coverity Scan false positives in SBuf

Coverity scanner gets badly confused with SBuf::npos being used as
default parameter value, even though its used to indicate that
strlen() needs to be used on the string.

This is an experiment to see if it gets less confused by having
explicit overloads for the two cases and not using SBuf::npos value
in relation to the unknown length c-strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
212
212
     * as needed.
213
213
     *
214
214
     * \param S the c string to be copied. Can be NULL.
215
 
     * \param Ssize how many bytes to import into the SBuf. If it is npos
216
 
     *              or unspecified, imports to end-of-cstring. If S is NULL,
217
 
     *              Ssize is ignored.
 
215
     * \param Ssize how many bytes to import into the SBuf.
 
216
     *              If S is NULL, Ssize is ignored.
218
217
     * \note to append a std::string use the pattern
219
218
     *     cstr_append(stdstr.data(), stdstd.length())
220
219
     */
221
 
    SBuf& append(const char * S, size_type Ssize = npos);
 
220
    SBuf& append(const char * S, size_type Ssize);
 
221
 
 
222
    /// \see SBuf& append(const char * S, size_type Ssize)
 
223
    SBuf& append(const char * S) {
 
224
        if (!S)
 
225
            return *this;
 
226
        return append(S, strlen(S));
 
227
    }
222
228
 
223
229
    /** Assignment operation with printf(3)-style definition
224
230
     * \note arguments may be evaluated more than once, be careful