added patches fixing covscan defects

This commit is contained in:
Michal Minar 2013-07-21 13:58:16 +02:00
parent 0defa8400c
commit aec60e8c78
3 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,12 @@
Index: hdparm-9.43/fallocate.c
===================================================================
--- hdparm-9.43.orig/fallocate.c
+++ hdparm-9.43/fallocate.c
@@ -41,6 +41,7 @@ int do_fallocate_syscall (const char *pa
exit(0);
}
err = errno;
+ close(fd);
unlink(path);
}
perror(path);

View File

@ -0,0 +1,47 @@
Index: hdparm-9.43/sgio.c
===================================================================
--- hdparm-9.43.orig/sgio.c
+++ hdparm-9.43/sgio.c
@@ -17,6 +17,10 @@
#include <linux/hdreg.h>
+#ifndef DEMAND_SENSE_DATA
+ #define DEMAND_SENSE_DATA 0
+#endif
+
extern int verbose;
extern int prefer_ata12;
@@ -193,7 +197,7 @@ int sg16 (int fd, int rw, int dma, struc
unsigned char cdb[SG_ATA_16_LEN];
unsigned char sb[32], *desc;
struct scsi_sg_io_hdr io_hdr;
- int prefer12 = prefer_ata12, demanded_sense = 0;
+ int prefer12 = prefer_ata12;
if (tf->command == ATA_OP_PIDENTIFY)
prefer12 = 0;
@@ -302,14 +306,16 @@ int sg16 (int fd, int rw, int dma, struc
desc = sb + 8;
if (io_hdr.driver_status != SG_DRIVER_SENSE) {
- if (sb[0] | sb[1] | sb[2] | sb[3] | sb[4] | sb[5] | sb[6] | sb[7] | sb[8] | sb[9]) {
- static int second_try = 0;
- if (!second_try++)
+ static int second_try = 0;
+ if (!second_try++) {
+ if (sb[0] | sb[1] | sb[2] | sb[3] | sb[4] | sb[5] | sb[6] | sb[7] | sb[8] | sb[9]) {
fprintf(stderr, "SG_IO: questionable sense data, results may be incorrect\n");
- } else if (demanded_sense) {
- static int second_try = 0;
- if (!second_try++)
+ }
+#if DEMAND_SENSE_DATA
+ else {
fprintf(stderr, "SG_IO: missing sense data, results may be incorrect\n");
+ }
+#endif
}
} else if (sb[0] != 0x72 || sb[7] < 14 || desc[0] != 0x09 || desc[1] < 0x0c) {
dump_bytes("SG_IO: bad/missing sense data, sb[]", sb, sizeof(sb));

View File

@ -1,13 +1,15 @@
Summary: A utility for displaying and/or setting hard disk parameters
Name: hdparm
Version: 9.43
Release: 2%{?dist}
Release: 3%{?dist}
License: BSD
Group: Applications/System
URL: http://sourceforge.net/projects/hdparm/
Source: http://download.sourceforge.net/hdparm/hdparm-%{version}.tar.gz
Patch0: hdparm-missing-params.patch
Patch1: man-page-update.patch
Patch2: %{name}-9.43-ditch_dead_code.patch
Patch3: %{name}-9.43-close_fd.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExcludeArch: s390 s390x
@ -20,6 +22,8 @@ performance and to spin down hard drives for power conservation.
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
CFLAGS="$RPM_OPT_FLAGS" make %{?_smp_mflags} STRIP=/bin/true LDFLAGS=
@ -40,6 +44,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man8/hdparm.8*
%changelog
* Sun Jul 21 2013 Michal Minar <miminar@redhat.com> 9.43-3
- Added patches fixing covscan defects.
* Fri Apr 19 2013 Michal Minar <miminar@redhat.com> 9.43-2
- Fixed inconsistency between man page and program's help.