Skip to content
  1. Feb 10, 2024
  2. Feb 08, 2024
  3. Feb 07, 2024
  4. Jan 30, 2024
  5. Jan 26, 2024
  6. Jan 20, 2024
  7. Dec 28, 2023
  8. Nov 30, 2023
  9. Oct 29, 2023
    • Mike Fleetwood's avatar
      Refactor xfs::set_used_sectors() into if fail return early pattern (!119) · 5a6b8afc
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Closes !119 -  Tidy-ups for file system interface classes
      5a6b8afc
    • Mike Fleetwood's avatar
      Refactor reiserfs::set_used_sectors() into if fail return early pattern (!119) · a6038282
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Closes !119 -  Tidy-ups for file system interface classes
      a6038282
    • Mike Fleetwood's avatar
      Refactor reiser4::set_used_sectors() into if fail return early pattern (!119) · 1f72c5f0
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Closes !119 -  Tidy-ups for file system interface classes
      1f72c5f0
    • Mike Fleetwood's avatar
      Refactor nilfs2::set_used_sectors() into if fail return early pattern (!119) · 9364923d
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Closes !119 -  Tidy-ups for file system interface classes
      9364923d
    • Mike Fleetwood's avatar
      Refactor ext2::set_used_sectors() into if fail return early (!119) · e565215a
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      ... code pattern.  This is to make the code easier to understand by not
      having to remember if condition context for indented code over longer
      distances.  This has been done before.  Here are just 2 examples:
      
      [1] 75bda733
          Refactor run_blkid_load_cache() into if fail return early (#131)
      [2] 407e0ac6
          Refactor fat16::read_label() into if fail return early pattern (!104)
      
      Closes !119 -  Tidy-ups for file system interface classes
      e565215a
    • Mike Fleetwood's avatar
      Remove now unused T, N & S FileSystem member variables (!119) · 5eef9049
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Now those member variables are unused remove them.
      
      Closes !119 -  Tidy-ups for file system interface classes
      5eef9049
    • Mike Fleetwood's avatar
      Stop using member variables T, N & S in xfs class (!119) · 9c6ea645
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Restructure the variable parsing code into "if leading text found then
      scan the number" pattern.
      
      Closes !119 -  Tidy-ups for file system interface classes
      9c6ea645
    • Mike Fleetwood's avatar
      Stop using member variables T, N & S in reiserfs class (!119) · 43a17ecd
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Restructure the variable parsing code into "if leading text found then
      scan the number" pattern.
      
      Anchor leading text matches to the start of a new line in the output.
      
      Closes !119 -  Tidy-ups for file system interface classes
      43a17ecd
    • Mike Fleetwood's avatar
      Stop using member variables T, N & S in reiser4 class (!119) · 334448d2
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Restructure the variable parsing code into "if leading text found then
      scan the number" pattern.
      
      Closes !119 -  Tidy-ups for file system interface classes
      334448d2
    • Mike Fleetwood's avatar
      Stop using member variables T, N & S in nilfs2 class (!119) · eadb18a9
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      And restructure the variable parsing code into "if leading text found
      then scan the number" pattern.
      
      Anchor leading text matches to the start of a new line in the output.
      
      Closes !119 -  Tidy-ups for file system interface classes
      eadb18a9
    • Mike Fleetwood's avatar
      Stop using member variables T & N in linux_swap, luks & lvm2_pv classes (!119) · c7faeeee
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Closes !119 -  Tidy-ups for file system interface classes
      c7faeeee
    • Mike Fleetwood's avatar
      Stop using member variables T, N & S in ext2 class (!119) · ef3e1d1c
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      FileSystem member variables T, N & S are being used like local variables
      in many of the file system specific set_used_sectors() methods.  They
      are only used within each set_used_sectors() call and not used to
      represent persistent information of a FileSystem interface class or to
      pass information between separate methods.  Therefore stop using them
      and replace them with local variables instead.
      
      This block of code finds a field in the output and scans the number:
          Glib::ustring::size_type index = output.find("Block count:");
          if (index >= output.length() ||
              sscanf(output.substr(index).c_str(), "Block count: %lld", &T) != 1)
                  T = -1;
      The if statement says "if leading text is not found or scanning the
      number fails then assign -1".  A sequence of two negatives leading to
      assigning an error value is hard to understand.  Instead this an
      equivalent block from btrfs::set_used_sectors():
          long long total_bytes = -1;
          Glib::ustring::size_type index = output.find("\ntotal_bytes");
          if (index < output.length())
                  sscanf(output.substr(index).c_str(), "\ntotal_bytes %lld", &total_bytes);
      This assigns a default error value and the if statement says "if leading
      text found then scan the number".  Much simpler to understand.
      Therefore change the code around to use this same pattern.
      
      Anchor the leading text matches to the start of a new line in the
      output where possible.  Just because it's what some of the other file
      system's set_used_sectors() methods do (btrfs, reiser4 and xfs) and it
      seems like more robust text matching.
      
      Closes !119 -  Tidy-ups for file system interface classes
      ef3e1d1c
    • Mike Fleetwood's avatar
      Stop using floating point calculation in most FS set_used_sectors() methods (!119) · 92dfbac0
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Replace floating point calculation to convert size and space figures
      from file system block sized units to sectors with an integer
      calculation.  Do this for the same reasons discussed in commit "Stop
      using floating point calculations in FS resize() methods" earlier in
      this patchset.  This will limit the largest file system that GParted can
      read the usage of to 8 EiB - 1 bytes.
      
      There is still a floating point calculation in btrfs::set_used_sectors()
      which is being left because that is apportioning used space figure
      between multiple devices.
      
      Closes !119 -  Tidy-ups for file system interface classes
      92dfbac0
    • Mike Fleetwood's avatar
      Reorder construction of ext2/3/4 resize command (!119) · 10e9f143
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      So that it is similar to other calls to execute_command() and for grep
      friendliness.
      
      Closes !119 -  Tidy-ups for file system interface classes
      10e9f143
    • Mike Fleetwood's avatar
      Reorder construction of nilfs2 resize command (!119) · 1d2a02b6
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Pass string literal containing the nilfs2 resize command to
      execute_command() rather than a string variable containing the same
      command.  This makes it the same as how most of the other calls to
      execute_command() are written and it makes it more grep friendly.
      
      Before:
          $ grep execute_command src/nilfs2.cc
              if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
              if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
              return ! execute_command( "nilfs-tune -L " + Glib::shell_quote( partition.get_filesystem_label() ) +
              if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
              return ! execute_command( "nilfs-tune -U " + Glib::shell_quote( Utils::generate_uuid() ) +
              return ! execute_command( "mkfs.nilfs2 -L " + Glib::shell_quote( new_partition.get_filesystem_label() ) +
                  success &= ! execute_command( "mount -v -t nilfs2 " + Glib::shell_quote( partition_new.get_path() ) +
      >>          success &= ! execute_command( cmd, operationdetail, EXEC_CHECK_STATUS );
                      success &= ! execute_command( "umount -v " + Glib::shell_quote( mount_point ),
      
      After:
          $ grep execute_command src/nilfs2.cc
              if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
              if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
              return ! execute_command( "nilfs-tune -L " + Glib::shell_quote( partition.get_filesystem_label() ) +
              if ( ! Utils::execute_command( "nilfs-tune -l " + Glib::shell_quote( partition.get_path() ),
              return ! execute_command( "nilfs-tune -U " + Glib::shell_quote( Utils::generate_uuid() ) +
              return ! execute_command( "mkfs.nilfs2 -L " + Glib::shell_quote( new_partition.get_filesystem_label() ) +
                  success &= ! execute_command( "mount -v -t nilfs2 " + Glib::shell_quote( partition_new.get_path() ) +
      >>          success &= ! execute_command("nilfs-resize -v -y " + Glib::shell_quote(partition_new.get_path()) + size,
                      success &= ! execute_command( "umount -v " + Glib::shell_quote( mount_point ),
      
      Closes !119 -  Tidy-ups for file system interface classes
      1d2a02b6
    • Mike Fleetwood's avatar
      Stop using floating point calculations in FS resize() methods (!119) · f098ba1e
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      A number of the file system specific resize() methods use floating point
      calculations to convert from the new partition size in sectors to the
      new file system size to be passed to the resize command in bytes or
      kibibytes.  This is bad because there could be rounding errors
      converting from integer to floating point, performing the calculation
      and converting back.  Replace with integer only multiply and divide
      calculations.  Integer division always truncates [1] which is exactly
      what is needed.  The largest integer will be the size of the file system
      in bytes held in a signed 64-bit long long, or Sector or Byte_Value
      typedef of the same type.  This will limit the size that a file system
      can be shrunk to, to 8 EiB - 1 byte.
      
      [1] C++ Arithmetic operators
          https://en.cppreference.com/w/cpp/language/operator_arithmetic
              "the algebraic quotient of integer division is truncated towards
              zero (fractional part is discarded)"
      
      Closes !119 -  Tidy-ups for file system interface classes
      f098ba1e
  10. Oct 22, 2023
  11. Oct 21, 2023
  12. Oct 19, 2023
  13. Oct 12, 2023
  14. Oct 05, 2023
  15. Oct 04, 2023
  16. Sep 23, 2023
    • Mike Fleetwood's avatar
      Replace deprecated Google Test API INSTANTIATE_TEST_CASE_P() (!117) · 2febe046
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      When compiling the tests, this warning is reported:
      
          $ make check
          ... warning: ...: INSTANTIATE_TEST_CASE_P is deprecated, please use INSTANTIATE_TEST_SUITE_P [-Wdeprecated-declarations]
             static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \
                                                ^
          test_SupportedFileSystems.cc:625:1: note: in expansion of macro 'INSTANTIATE_TEST_CASE_P'
      
      Google Test 1.10.0 release notes [1] say:
          High Level Changes:
          This release deprecated "....TEST_CASE" API in favor of
          "....TEST_SUITE".  In a nutshell if you have code that uses
          something like "INSTANTIATE_TYPED_TEST_CASE_P " - this and all other
          "*_TEST_CASE " are now deprecated in favor of more standard
          _TEST_SUITE.
      
      Replace the deprecated API with the new API.
      
      [1] Google Test release v1.10.0
          https://github.com/google/googletest/releases/tag/release-1.10.0
      
      Closes !117 - Require C++11 compilation
      2febe046
    • Mike Fleetwood's avatar
      Update to Google Test 1.10.0 (!117) · 1ccb7821
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      So far GParted includes Google Test 1.8.1 [1], which was the latest
      release which supported pre-C++11 compilers [2].  Now that GParted
      requires C++11 compilation, update to Google Test 1.10.0.  Replace the
      following files and directories from Google Test 1.10.0:
          LICENSE
          README.md
          include/
          src/
      Note the LICENSE file is identical, where as the other files have
      changed.  This includes file additions and removals, hence the change
      to Makefile.am too.
      
      Even though Google Test releases up to and including 1.12.1 are
      compilable with C++11 compilers [3], it is not possible to upgrade
      beyond Google Test 1.10.0 at this time because later releases fail to
      compile on on still supported RHEL / CentOS 7 with this error:
      
          $ cd lib/gtest
          $ make check
          ...
          ./include/gtest/gtest-matchers.h:414:12: error: 'is_trivially_copy_constructible' is not a member of 'std'
                      std::is_trivially_copy_constructible<M>::value &&
                      ^
      
      This failur...
      1ccb7821
    • Mike Fleetwood's avatar
      C++11: Also convert NULL to nullptr in unit tests (!117) · 3b469273
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      Closes !117 - Require C++11 compilation
      3b469273
    • Mike Fleetwood's avatar
      C++11: Convert NULL to nullptr (!117) · 40665913
      Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
      In C++11, nullptr [1] is the strongly typed value to use instead of the
      macro NULL [2].  Use everywhere [3][4].
      
      [1] nullptr, the pointer literal (since C++11)
          https://en.cppreference.com/w/cpp/language/nullptr
      [2] NULL
          https://en.cppreference.com/w/cpp/types/NULL
      [3] Bjarne Stroustrup's C++ Style and Technique FAQ, Should I use NULL
          or 0?
          https://www.stroustrup.com/bs_faq2.html#null
              "In C++, the definition of NULL is 0, so there is only an
              aesthetic difference.  I prefer to avoid macros, so I use 0.
              Another problem with NULL is that people sometimes mistakenly
              believe that it is different from 0 and/or not an integer.  In
              pre-standard code, NULL was/is sometimes defined to something
              unsuitable and therefore had/has to be avoided.  That's less
              common these days.
      
              If you have to name the null pointer, call it nullptr; that's
              what it's called in C++11.  Then, "nullptr" will be a keyw...
      40665913