Silence coverity warning about sizeof(Node*) vs sizeof(Node) in QList

Coverity was complaining about QList::node_copy using sizeof(Node *)
instead of sizeof(Node).  The complete message from Coverity is:

"Passing argument "from" of type "struct QList<QObject *>::Node *" and
argument "(to - from) * sizeof (struct QList<QObject *>::Node *) /*4*/"
to function "memcpy" is suspicious. Did you intend to use "sizeof(struct
QList<QObject *>::Node)" instead of "sizeof (struct
QList<QObject *>::Node *)" ? In this particular case sizeof(struct
QList<QObject *>::Node *) happens to be equal to sizeof(struct
QList<QObject *>::Node), but this is not a portable assumption."

Task-number: QTBUG-24443
Change-Id: I583887a8b4177a224664065e14f8780a9586c9a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Andy Shaw 2012-02-22 13:28:44 +01:00 committed by Qt by Nokia
parent 1f80ce8135
commit 8bf009e216

View File

@ -402,7 +402,7 @@ Q_INLINE_TEMPLATE void QList<T>::node_copy(Node *from, Node *to, Node *src)
}
} else {
if (src != from && to - from > 0)
memcpy(from, src, (to - from) * sizeof(Node *));
memcpy(from, src, (to - from) * sizeof(Node));
}
}