snprintf deals well with NULL/0 buffers. Basically this undoes
6555fa9d8fbc and
193df617.
6555fa9d8fbc gave cppcheck as a reason for
this patch, but if I look into susv4's snprintf definition I find:
If n is zero, nothing shall be written and s may be a null pointer.
This removes the checks and makes sure we fulfill the requirement of
susv4 that states that buf can only be NULL if buflen is 0.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
{
int len = 0;
- if ((buf == NULL) || (buflen == 0)) {
- return strlen(fsp->conn->connectpath) + 1 +
- strlen(fsp->fsp_name->base_name);
+ if (buf == NULL) {
+ /*
+ * susv4 allows buf==NULL if buflen==0 for snprintf.
+ */
+ SMB_ASSERT(buflen == 0);
}
len = snprintf(buf, buflen, "%s/%s", fsp->conn->connectpath,