From patchwork Tue May 19 21:22:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 6440631 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 16AD59F1C1 for ; Tue, 19 May 2015 21:23:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27DFD2037E for ; Tue, 19 May 2015 21:23:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F90F2035B for ; Tue, 19 May 2015 21:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751588AbbESVXB (ORCPT ); Tue, 19 May 2015 17:23:01 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:52767 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751345AbbESVW6 (ORCPT ); Tue, 19 May 2015 17:22:58 -0400 Received: from wuerfel.localnet ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MYvrP-1Ygqkj2TP1-00VdJG; Tue, 19 May 2015 23:22:42 +0200 From: Arnd Bergmann To: Andrew Morton Cc: Dave Gordon , "Martin K. Petersen" , Akinobu Mita , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, jbottomley@odin.com Subject: [PATCH] scsi: debug: fix type mismatch warning for sg_pcopy_from_buffer Date: Tue, 19 May 2015 23:22:39 +0200 Message-ID: <6309932.EjHf7uUo1X@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:wCxl7SKnxf7BBfr36c5/oUpiWkR3PrlGrI6Z23vxUx2KSANOy/8 jafjiUp25ySL408PJfhjTuY0yZdn1l5oav3wJidnR8pBsIeAp14BHrvdvgHGXn1dJsdF2H6 m54wCERa2opS//bkj9IC0r5/j5df032ODbbmz/rAFiIX5D9lG58FCB5r1wET5DYjf0lLuZb mQT5nlMD2RuVlQSyqldhA== X-UI-Out-Filterresults: notjunk:1; Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The recent change to mark the input argument of sg_pcopy_from_buffer had the unfortunate side-effect to cause a new warning in the scsi_debug code: drivers/scsi/scsi_debug.c: In function 'do_device_access': drivers/scsi/scsi_debug.c:2376:8: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types] func = sg_pcopy_from_buffer; This patch attempts to avoid that warning without adding evil type casts, but unfortunately makes the do_device_access function a lot uglier in the process. Signed-off-by: Arnd Bergmann Fixes: 5250326459 ("lib/scatterlist: mark input buffer parameters as 'const'") --- I can't decide if this is actually a good idea, or if we should rather drop the sg_pcopy_from_buffer() patch. Maybe someone else sees a better solution. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 1f8e2dc9c616..dd9f0d1574ef 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2363,17 +2363,13 @@ do_device_access(struct scsi_cmnd *scmd, u64 lba, u32 num, bool do_write) u64 block, rest = 0; struct scsi_data_buffer *sdb; enum dma_data_direction dir; - size_t (*func)(struct scatterlist *, unsigned int, void *, size_t, - off_t); if (do_write) { sdb = scsi_out(scmd); dir = DMA_TO_DEVICE; - func = sg_pcopy_to_buffer; } else { sdb = scsi_in(scmd); dir = DMA_FROM_DEVICE; - func = sg_pcopy_from_buffer; } if (!sdb->length) @@ -2385,17 +2381,29 @@ do_device_access(struct scsi_cmnd *scmd, u64 lba, u32 num, bool do_write) if (block + num > sdebug_store_sectors) rest = block + num - sdebug_store_sectors; - ret = func(sdb->table.sgl, sdb->table.nents, - fake_storep + (block * scsi_debug_sector_size), - (num - rest) * scsi_debug_sector_size, 0); + if (do_write) + ret = sg_pcopy_to_buffer(sdb->table.sgl, sdb->table.nents, + fake_storep + (block * scsi_debug_sector_size), + (num - rest) * scsi_debug_sector_size, 0); + else + ret = sg_pcopy_from_buffer(sdb->table.sgl, sdb->table.nents, + fake_storep + (block * scsi_debug_sector_size), + (num - rest) * scsi_debug_sector_size, 0); + if (ret != (num - rest) * scsi_debug_sector_size) return ret; - if (rest) { - ret += func(sdb->table.sgl, sdb->table.nents, - fake_storep, rest * scsi_debug_sector_size, - (num - rest) * scsi_debug_sector_size); - } + if (!rest) + return ret; + + if (do_write) + ret += sg_pcopy_to_buffer(sdb->table.sgl, sdb->table.nents, + fake_storep, rest * scsi_debug_sector_size, + (num - rest) * scsi_debug_sector_size); + else + ret += sg_pcopy_from_buffer(sdb->table.sgl, sdb->table.nents, + fake_storep, rest * scsi_debug_sector_size, + (num - rest) * scsi_debug_sector_size); return ret; }