HydrologicEngineeringCenter / hec-dss

source code for HEC-DSS (Data Storage System)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

magic number 392 should be removed (it is very close to #define MAX_PATHNAME_LENGTH 393)

ktarbet opened this issue · comments

The number 393 is used in both Fortran and C code in several places. Usually related to a maximum total length of a pathname.

Nothing should've been 393. I think that number came from someone thinking a pathname could have 392 characters, which which it could not have. The max number of characters with 64-character parts = 6 (parts) * 64 chars + 7 slash chars = 391 characters. So the max length was 391 which should be used in Fortran, and the max char array size in C would be 392 to accommodate the trailing NULL. So these should've been the definitions, with 393 nowhere in sight:

  • MAX_PART_LENGTH = 64
  • MAX_PART_SIZE = 65
  • MAX_PATHNAME_LEN = 391
  • MAX_PATHNAME_SIZE = 392
    In our current state with increased part length, but same pathname length, they should be:
  • MAX_PART_LENGTH = 128
  • MAX_PART_SIZE = 129
  • MAX_PATHNAME_LEN = 391
  • MAX_PATHNAME_SIZE = 392
    If we allow all parts to be 128 characters, the values should go to
  • MAX_PART_LENGTH = 128
  • MAX_PART_SIZE = 129
  • MAX_PATHNAME_LEN = 775
  • MAX_PATHNAME_SIZE = 776