Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] media: Use strlcpy instead of custom code

Replace strncpy + manually setting the terminating '\0' with an strlcpy
call.

Reported-by: Joe Perches <joe@perches.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
de8eae36 62ea864f

+2 -4
+2 -4
drivers/media/media-device.c
··· 103 103 return -EINVAL; 104 104 105 105 u_ent.id = ent->id; 106 - if (ent->name) { 107 - strncpy(u_ent.name, ent->name, sizeof(u_ent.name)); 108 - u_ent.name[sizeof(u_ent.name) - 1] = '\0'; 109 - } 106 + if (ent->name) 107 + strlcpy(u_ent.name, ent->name, sizeof(u_ent.name)); 110 108 u_ent.type = ent->type; 111 109 u_ent.revision = ent->revision; 112 110 u_ent.flags = ent->flags;