1
0
Fork 0

[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>
hifive-unleashed-5.1
Laurent Pinchart 2014-07-17 08:52:08 -03:00 committed by Mauro Carvalho Chehab
parent 62ea864f84
commit de8eae3605
1 changed files with 2 additions and 4 deletions

View File

@ -103,10 +103,8 @@ static long media_device_enum_entities(struct media_device *mdev,
return -EINVAL;
u_ent.id = ent->id;
if (ent->name) {
strncpy(u_ent.name, ent->name, sizeof(u_ent.name));
u_ent.name[sizeof(u_ent.name) - 1] = '\0';
}
if (ent->name)
strlcpy(u_ent.name, ent->name, sizeof(u_ent.name));
u_ent.type = ent->type;
u_ent.revision = ent->revision;
u_ent.flags = ent->flags;