Message ID | 20181017082702.5581-39-armbru@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Replace some unwise uses of error_report() & friends | expand |
Am 17.10.2018 um 10:27 hat Markus Armbruster geschrieben: > vpc_open() merely prints a warning when it finds a bad header > checksum. Turn that into a hard error. > > Cc: Kevin Wolf <kwolf@redhat.com> > Signed-off-by: Markus Armbruster <armbru@redhat.com> > --- > block/vpc.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/block/vpc.c b/block/vpc.c > index bf294abfa7..1729c0cb44 100644 > --- a/block/vpc.c > +++ b/block/vpc.c > @@ -284,9 +284,11 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, > > checksum = be32_to_cpu(footer->checksum); > footer->checksum = 0; > - if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) > - fprintf(stderr, "block-vpc: The header checksum of '%s' is " > - "incorrect.\n", bs->filename); > + if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) { > + error_setg(errp, "incorrect header checksum"); Upper case would be more consistent with most other error messages in the vpc driver. > + ret = -EINVAL; > + goto fail; > + } With that fixed: Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Kevin Wolf <kwolf@redhat.com> writes: > Am 17.10.2018 um 10:27 hat Markus Armbruster geschrieben: >> vpc_open() merely prints a warning when it finds a bad header >> checksum. Turn that into a hard error. >> >> Cc: Kevin Wolf <kwolf@redhat.com> >> Signed-off-by: Markus Armbruster <armbru@redhat.com> >> --- >> block/vpc.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/block/vpc.c b/block/vpc.c >> index bf294abfa7..1729c0cb44 100644 >> --- a/block/vpc.c >> +++ b/block/vpc.c >> @@ -284,9 +284,11 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, >> >> checksum = be32_to_cpu(footer->checksum); >> footer->checksum = 0; >> - if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) >> - fprintf(stderr, "block-vpc: The header checksum of '%s' is " >> - "incorrect.\n", bs->filename); >> + if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) { >> + error_setg(errp, "incorrect header checksum"); > > Upper case would be more consistent with most other error messages in > the vpc driver. Sure. >> + ret = -EINVAL; >> + goto fail; >> + } > > With that fixed: > > Reviewed-by: Kevin Wolf <kwolf@redhat.com> Thanks!
diff --git a/block/vpc.c b/block/vpc.c index bf294abfa7..1729c0cb44 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -284,9 +284,11 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags, checksum = be32_to_cpu(footer->checksum); footer->checksum = 0; - if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) - fprintf(stderr, "block-vpc: The header checksum of '%s' is " - "incorrect.\n", bs->filename); + if (vpc_checksum(s->footer_buf, HEADER_SIZE) != checksum) { + error_setg(errp, "incorrect header checksum"); + ret = -EINVAL; + goto fail; + } /* Write 'checksum' back to footer, or else will leave it with zero. */ footer->checksum = cpu_to_be32(checksum);
vpc_open() merely prints a warning when it finds a bad header checksum. Turn that into a hard error. Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> --- block/vpc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)