On Tue, Feb 28, 2012 at 7:35 PM, Alex Elder <elder@xxxxxxxxxxxxx> wrote: > From Josh Durgin <josh.durgin@xxxxxxxxxxxxx> > > There's already a constant for this anyway. > > (I changed Josh's code to use memcmp() and memcpy() instead. -Alex) > > Signed-off-by: Alex Elder <elder@xxxxxxxxxxxxx> > --- > drivers/block/rbd.c | 8 +++----- > 1 files changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c > index 3d0f8cf..25ed3c0 100644 > --- a/drivers/block/rbd.c > +++ b/drivers/block/rbd.c > @@ -563,10 +563,7 @@ static int rbd_header_set_snap(struct rbd_device *dev, > > down_write(&header->snap_rwsem); > > - if (!snap_name || > - !*snap_name || > - strcmp(snap_name, "-") == 0 || > - strcmp(snap_name, RBD_SNAP_HEAD_NAME) == 0) { > + if (!memcmp(snap_name, RBD_SNAP_HEAD_NAME, sizeof The original code checked for snap_name, we don't do it here. Also, do we know that snap_name is pointing to at least sizeof(RBD_SNAP_HEAD_NAME)? if not (or in any case) we should use strcmp instead of memcmp. Also, sizeof(x) instead of sizeof x. > RBD_SNAP_HEAD_NAME)) { > if (header->total_snaps) > snapc->seq = header->snap_seq; > else > @@ -2213,7 +2210,8 @@ static ssize_t rbd_add(struct bus_type *bus, > } > > if (rbd_dev->snap_name[0] == 0) > - rbd_dev->snap_name[0] = '-'; > + memcpy(rbd_dev->snap_name, RBD_SNAP_HEAD_NAME, > + sizeof RBD_SNAP_HEAD_NAME); > > rbd_dev->obj_len = strlen(rbd_dev->obj); > snprintf(rbd_dev->obj_md_name, sizeof(rbd_dev->obj_md_name), "%s%s", > -- > 1.7.5.4 > > -- > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html