diff mbox

[v2,3/7] block/sheepdog: remove spurious NULL check

Message ID 8fe8ddad6b924b460ca4ed4a7e401c18d24c246f.1504112061.git.jcody@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Cody Aug. 30, 2017, 4:57 p.m. UTC
'tag' is already checked in the lines immediately preceding this check,
and set to non-NULL if NULL.  No need to check again, it hasn't changed.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block/sheepdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Aug. 30, 2017, 5:37 p.m. UTC | #1
On Wed, Aug 30, 2017 at 1:57 PM, Jeff Cody <jcody@redhat.com> wrote:
> 'tag' is already checked in the lines immediately preceding this check,
> and set to non-NULL if NULL.  No need to check again, it hasn't changed.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/sheepdog.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index abb2e79..bbbfa72 100644
> --- a/block/sheepdog.c
> +++ b/block/sheepdog.c
> @@ -1632,7 +1632,7 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags,
>      if (!tag) {
>          tag = "";
>      }
> -    if (tag && strlen(tag) >= SD_MAX_VDI_TAG_LEN) {
> +    if (strlen(tag) >= SD_MAX_VDI_TAG_LEN) {

you can even prepend an 'else'! :D

>          error_setg(errp, "value of parameter 'tag' is too long");
>          ret = -EINVAL;
>          goto err_no_fd;
> --
> 2.9.5
>
>
Eric Blake Aug. 30, 2017, 7:42 p.m. UTC | #2
On 08/30/2017 11:57 AM, Jeff Cody wrote:
> 'tag' is already checked in the lines immediately preceding this check,
> and set to non-NULL if NULL.  No need to check again, it hasn't changed.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/sheepdog.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/block/sheepdog.c b/block/sheepdog.c
index abb2e79..bbbfa72 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1632,7 +1632,7 @@  static int sd_open(BlockDriverState *bs, QDict *options, int flags,
     if (!tag) {
         tag = "";
     }
-    if (tag && strlen(tag) >= SD_MAX_VDI_TAG_LEN) {
+    if (strlen(tag) >= SD_MAX_VDI_TAG_LEN) {
         error_setg(errp, "value of parameter 'tag' is too long");
         ret = -EINVAL;
         goto err_no_fd;