From aec60e8c781286d682224d4dbe65689977893d64 Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Sun, 21 Jul 2013 13:58:16 +0200 Subject: [PATCH] added patches fixing covscan defects --- hdparm-9.43-close_fd.patch | 12 ++++++++ hdparm-9.43-ditch_dead_code.patch | 47 +++++++++++++++++++++++++++++++ hdparm.spec | 9 +++++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 hdparm-9.43-close_fd.patch create mode 100644 hdparm-9.43-ditch_dead_code.patch diff --git a/hdparm-9.43-close_fd.patch b/hdparm-9.43-close_fd.patch new file mode 100644 index 0000000..533b18e --- /dev/null +++ b/hdparm-9.43-close_fd.patch @@ -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); diff --git a/hdparm-9.43-ditch_dead_code.patch b/hdparm-9.43-ditch_dead_code.patch new file mode 100644 index 0000000..4f4f177 --- /dev/null +++ b/hdparm-9.43-ditch_dead_code.patch @@ -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 + ++#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)); diff --git a/hdparm.spec b/hdparm.spec index 0ddda59..ac0ab73 100644 --- a/hdparm.spec +++ b/hdparm.spec @@ -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 9.43-3 +- Added patches fixing covscan defects. + * Fri Apr 19 2013 Michal Minar 9.43-2 - Fixed inconsistency between man page and program's help.