LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: Borislav Petkov <petkovbb@googlemail.com>
Cc: bzolnier@gmail.com, linux-kernel@vger.kernel.org,
	linux-ide@vger.kernel.org, Borislav Petkov <petkovbb@gmail.com>
Subject: Re: [PATCH 06/22] ide-tape: struct idetape_tape_t: remove unused members
Date: Mon, 22 Sep 2008 17:25:41 +0400	[thread overview]
Message-ID: <48D79CD5.5000605@ru.mvista.com> (raw)
In-Reply-To: <1202132440-26648-7-git-send-email-petkovbb@gmail.com>

Hello.

Borislav Petkov wrote:

> - last_frame_position: only being written to once
> - firmware_revision, product_id, vendor_id: used once, remove from struct
>   idetape_tape_t and deal with them locally
> - firmware_revision_num: only written to once
> - tape_still_time_begin: completely unused
> - tape_still_time: never written to; remove corresponding code chunk
> - uncontrolled_last_pipeline_head: only once written to
> - blocks_in_buffer: only written to

> Signed-off-by: Borislav Petkov <petkovbb@gmail.com>

    Late complaint but anyway... :-)

> diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
> index e0e8184..126e8a9 100644
> --- a/drivers/ide/ide-tape.c
> +++ b/drivers/ide/ide-tape.c
> @@ -399,11 +397,6 @@ typedef struct ide_tape_obj {
>  	int avg_size;
>  	int avg_speed;
>  
> -	char vendor_id[10];
> -	char product_id[18];
> -	char firmware_revision[6];
> -	int firmware_revision_num;
> -
>  	/* the door is currently locked */
>  	int door_locked;
>  	/* the tape hardware is write protected */

[...]

> @@ -3438,9 +3419,9 @@ static int idetape_identify_device (ide_drive_t *drive)
>  
>  static void idetape_get_inquiry_results(ide_drive_t *drive)
>  {
> -	char *r;
>  	idetape_tape_t *tape = drive->driver_data;
>  	idetape_pc_t pc;
> +	char fw_rev[6], vendor_id[10], product_id[18];
>  
>  	idetape_create_inquiry_cmd(&pc);
>  	if (idetape_queue_pc_tail(drive, &pc)) {
> @@ -3448,20 +3429,16 @@ static void idetape_get_inquiry_results(ide_drive_t *drive)
>  				tape->name);
>  		return;
>  	}
> -	memcpy(tape->vendor_id, &pc.buffer[8], 8);
> -	memcpy(tape->product_id, &pc.buffer[16], 16);
> -	memcpy(tape->firmware_revision, &pc.buffer[32], 4);
> -
> -	ide_fixstring(tape->vendor_id, 10, 0);
> -	ide_fixstring(tape->product_id, 18, 0);
> -	ide_fixstring(tape->firmware_revision, 6, 0);
> -	r = tape->firmware_revision;
> -	if (*(r + 1) == '.')
> -		tape->firmware_revision_num = (*r - '0') * 100 +
> -			(*(r + 2) - '0') * 10 +	*(r + 3) - '0';
> +	memcpy(vendor_id, &pc.buffer[8], 8);
> +	memcpy(product_id, &pc.buffer[16], 16);
> +	memcpy(fw_rev, &pc.buffer[32], 4);
> +
> +	ide_fixstring(vendor_id, 10, 0);
> +	ide_fixstring(product_id, 18, 0);
> +	ide_fixstring(fw_rev, 6, 0);

    It was wrong to call ide_fixstring() on unterminated strings and expecting 
them to become terminated strings after that; plus it was useless to add 2 
characters padding at the end. When these variables were the fields of 'struct 
ide_tape_obj', those bytes were 0 because of the variable of this type being a 
static array. When they became local variables, they got garbage bytes at the 
end which ide_fixdriveid() either honestly copied when compressing spaces or 
just left where they were...

> +
>  	printk(KERN_INFO "ide-tape: %s <-> %s: %s %s rev %s\n",

    Should've rather changed the string format to print only N characters max...

MBR, Sergei

  reply	other threads:[~2008-09-22 13:24 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04 13:40 Borislav Petkov
2008-02-04 13:40 ` [PATCH 01/22] ide-tape: refactor the debug logging facility Borislav Petkov
2008-02-04 13:40 ` [PATCH 02/22] ide-tape: remove struct idetape_read_position_result_t Borislav Petkov
2008-02-05  1:23   ` Bartlomiej Zolnierkiewicz
2008-02-04 13:40 ` [PATCH 03/22] ide-tape: remove unreachable code chunk Borislav Petkov
2008-02-04 13:40 ` [PATCH 04/22] ide-tape: simplify code branching in the interrupt handler Borislav Petkov
2008-02-04 13:40 ` [PATCH 05/22] ide-tape: remove typedef idetape_chrdev_direction_t Borislav Petkov
2008-02-04 13:40 ` [PATCH 06/22] ide-tape: struct idetape_tape_t: remove unused members Borislav Petkov
2008-09-22 13:25   ` Sergei Shtylyov [this message]
2008-09-22 13:58     ` Boris Petkov
2008-09-22 15:50       ` Sergei Shtylyov
2008-02-04 13:40 ` [PATCH 07/22] ide-tape: struct idetape_tape_t: shorten member names v2 Borislav Petkov
2008-02-05  1:23   ` Bartlomiej Zolnierkiewicz
2008-02-05  4:47     ` Borislav Petkov
2008-02-04 13:40 ` [PATCH 08/22] ide-tape: remove packet command and struct request memory buffers Borislav Petkov
2008-02-04 13:40 ` [PATCH 09/22] ide-tape: remove idetape_increase_max_pipeline_stages() Borislav Petkov
2008-02-04 13:40 ` [PATCH 10/22] ide-tape: shorten some function names Borislav Petkov
2008-02-04 13:40 ` [PATCH 11/22] ide-tape: remove atomic test/set macros Borislav Petkov
2008-02-04 13:40 ` [PATCH 12/22] ide-tape: dump gcw fields on error in idetape_identify_device() Borislav Petkov
2008-02-04 13:40 ` [PATCH 13/22] ide-tape: remove struct idetape_id_gcw Borislav Petkov
2008-02-04 13:40 ` [PATCH 14/22] ide-tape: cleanup and fix comments Borislav Petkov
2008-02-05  1:27   ` Bartlomiej Zolnierkiewicz
2008-02-04 13:40 ` [PATCH 15/22] ide-tape: remove unused "length" arg from idetape_create_read_buffer_cmd() Borislav Petkov
2008-02-04 13:40 ` [PATCH 16/22] ide-tape: include proper headers Borislav Petkov
2008-02-04 13:40 ` [PATCH 17/22] ide-tape: collect module-related macro calls at the end Borislav Petkov
2008-02-04 13:40 ` [PATCH 18/22] ide-tape: remove leftover OnStream support warning Borislav Petkov
2008-02-04 13:40 ` [PATCH 19/22] ide-tape: fix syntax error in idetape_identify_device() Borislav Petkov
2008-02-04 13:40 ` [PATCH 20/22] ide-tape: cleanup the remaining codestyle issues Borislav Petkov
2008-02-05  1:27   ` Bartlomiej Zolnierkiewicz
2008-02-04 13:40 ` [PATCH 21/22] ide-tape: bump minor driver version Borislav Petkov
2008-02-04 13:40 ` [PATCH 22/22] ide-tape: schedule driver for removal after 6 months in case it turns out Borislav Petkov
2008-02-05  1:20 ` ide-tape redux (was: Bartlomiej Zolnierkiewicz
2008-02-06  5:23   ` Borislav Petkov
2008-02-06  5:27     ` Borislav Petkov
2008-02-09 16:25       ` Bartlomiej Zolnierkiewicz
2008-02-09 19:42         ` [PATCH 1/2] ide-tape: move all struct and other defs at the top Borislav Petkov
2008-02-11 22:12           ` Bartlomiej Zolnierkiewicz
2008-02-09 16:25     ` ide-tape redux (was: Bartlomiej Zolnierkiewicz
2008-02-09 19:43       ` [PATCH 2/2] ide-tape: remove atomic test/set macros for packet commands Borislav Petkov
2008-02-11 22:12         ` Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48D79CD5.5000605@ru.mvista.com \
    --to=sshtylyov@ru.mvista.com \
    --cc=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petkovbb@gmail.com \
    --cc=petkovbb@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).