From patchwork Sun Sep 25 11:30:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8489DC04A95 for ; Sun, 25 Sep 2022 12:14:17 +0000 (UTC) Received: from localhost ([::1]:44238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQWW-0001hs-DV for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPs8-0003Nb-Fb; Sun, 25 Sep 2022 07:32:33 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:46660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPs3-0006Rt-7N; Sun, 25 Sep 2022 07:32:28 -0400 Received: by mail-pf1-x42e.google.com with SMTP id c198so4138848pfc.13; Sun, 25 Sep 2022 04:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OBfXa3xFVi4lbcy7vm7XKQ/MxZiXQOmmQuqalNwWIA4=; b=dCsDknvWnfotQeY7AC9SontTAI7/UX8fr/91Hfq9NBI4f91dl3DmCkLjGFcfdu8u+L CArNlDYUIrvqe72Wl9hSFAYLgb4C2ykB31jcboIUwmjxJzAcp26HTdalE0WepR7Yi87N rBTL6y3gqcmquY0hibe0L/jq7PC2JBQpKRnGbTOtSkDZXtq8V9zISe/dtkwpTbK+sB6p Ar+AixcHICI/8sx5foVDEWM2uVt7bZWyGNcxz6E1pA6SgYmMrE0zxtC0xLptEn8qRCWg 2LU/CqEEO9tCyQj1gxVuhRPM8+L4lbiyGRtlXFoxBpgJUPLLCGnqTP6L9MPWpzk4h9N/ 171A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=OBfXa3xFVi4lbcy7vm7XKQ/MxZiXQOmmQuqalNwWIA4=; b=Mf1FTmsUkGQRBaJuxTvjkPmfHUw/GWFgDjfFc2YP3DLAOoxarokI2Sd3AaD2R8nRjT vzuBqM084gMY56nVlhv3asnKCLMmgKWOK3puNWjZ4n4XBmUO5Ln+ocQdEsBISVGnqRfW 2QG2PYY7mQ+NhFJpGYEYSBWXZ8qx+nElARSHqJmzv/MwHGsEVWWpcCz/WnoLWDlq3lBv mtgYFb8BPuPzjqff0Xiz45L5Hf+acx7RvW0lSURafnFEdeL6Lhbty0KvSyDU6xIxnAYl lW0GSeF8TqfR9I0tyWwSBp7TfBT8kHvbJsl9JZLQuhFwZ0vlZftbvB0iSOnsXoKlDv94 9JJg== X-Gm-Message-State: ACrzQf3JOSx4tRsNXu5DX9JrZ7juUuFehQyzAubQKOHrO4XciWVsNJph vt9eQ28PnYqZONqp9QF/3zxuRIWfNK8= X-Google-Smtp-Source: AMsMyM62rQF2HCdx52L2ETTIilN+MAkxuVk8L/p1GhZGWYqDye0ZHnw+4ZI23tvKFcj+MdFfMbiAJA== X-Received: by 2002:a63:698a:0:b0:41c:8dfa:e622 with SMTP id e132-20020a63698a000000b0041c8dfae622mr15084465pgc.465.1664105544646; Sun, 25 Sep 2022 04:32:24 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:24 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v3 40/54] tests/qtest: ide-test: Open file in binary mode Date: Sun, 25 Sep 2022 19:30:18 +0800 Message-Id: <20220925113032.1949844-41-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng By default Windows opens file in text mode, while a POSIX compliant implementation treats text files and binary files the same. The fopen() 'mode' string can include the letter 'b' to indicate binary mode shall be used. POSIX spec says the character 'b' shall have no effect, but is allowed for ISO C standard conformance. Let's add the letter 'b' which works on both POSIX and Windows. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Drop ahci-test.c changes that are no longer needed tests/qtest/ide-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c index 5e3e28aea2..4ea89c26c9 100644 --- a/tests/qtest/ide-test.c +++ b/tests/qtest/ide-test.c @@ -892,7 +892,7 @@ static void cdrom_pio_impl(int nblocks) /* Prepopulate the CDROM with an interesting pattern */ generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); - fh = fopen(tmp_path, "w+"); + fh = fopen(tmp_path, "wb+"); ret = fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh); g_assert_cmpint(ret, ==, patt_blocks); fclose(fh); @@ -993,7 +993,7 @@ static void test_cdrom_dma(void) prdt[0].size = cpu_to_le32(len | PRDT_EOT); generate_pattern(pattern, ATAPI_BLOCK_SIZE * 16, ATAPI_BLOCK_SIZE); - fh = fopen(tmp_path, "w+"); + fh = fopen(tmp_path, "wb+"); ret = fwrite(pattern, ATAPI_BLOCK_SIZE, 16, fh); g_assert_cmpint(ret, ==, 16); fclose(fh);