FreeCalypso > hg > freecalypso-tools
view ffstools/tiffs-mkfs/ffsparam.c @ 964:a96cb97b66a2
ringtools/imy: fix duplicate definition of tdma_durations[]
The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>,
although the present fix is slightly different from the contributed
patch: because main.c doesn't need this tdma_durations[] array
at all, let's simply remove the reference to this array from main.c
rather than turn it into an extern.
I no longer remember my original thought flow that resulted (by mistake)
in tdma_durations[] being multiply defined in main.c and durations.c.
My intent might have been to define all globals in main.c and have
the reference in durations.c be an extern - and I missed that extern -
but without clear memory, I have no certainty. In any case, having
this data array defined in the same module that fills it (durations.c)
is sensible, so let's make it the new way.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 31 Aug 2023 19:38:18 +0000 |
parents | 178ed445021d |
children |
line wrap: on
line source
#include <sys/types.h> #include <sys/param.h> #include <ctype.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "struct.h" #include "globals.h" void parse_org_arg(arg) char *arg; { char *cp; cp = index(arg, 'x'); if (!cp || !isdigit(cp[1]) || !isdigit(arg[0])) { fprintf(stderr, "error: TIFFS organization argument \"%s\" is invalid\n", arg); exit(1); } *cp++ = '\0'; if (!strcmp(arg, "8")) ffs_sector_size = 0x2000; else if (!strcmp(arg, "16")) ffs_sector_size = 0x4000; else if (!strcmp(arg, "32")) ffs_sector_size = 0x8000; else if (!strcmp(arg, "64")) ffs_sector_size = 0x10000; else if (!strcmp(arg, "128")) ffs_sector_size = 0x20000; else if (!strcmp(arg, "256")) ffs_sector_size = 0x40000; else { fprintf(stderr, "error: \"%s\" is not a recognized flash sector size\n", arg); exit(1); } ffs_nsectors = atoi(cp); if (ffs_nsectors < 3 || ffs_nsectors > 128) { fprintf(stderr, "error: \"%s\" is not a reasonable number of FFS sectors\n", cp); exit(1); } } void preen_chunk_size_max() { if (chunk_size_max) { if (chunk_size_max > ffs_sector_size / 2) { fprintf(stderr, "error: max chunk size specified with -c is too large\n"); exit(1); } return; } /* default matching TI's code */ if (ffs_sector_size * ffs_nsectors > 1024*1024) chunk_size_max = 8192; else if (ffs_sector_size / 8 < 2048) chunk_size_max = ffs_sector_size / 8; else chunk_size_max = 2048; } void preen_journal_size() { if (journal_size) return; /* default matching TI's code */ journal_size = ffs_sector_size >> 4; if (journal_size < 1024) journal_size = 1024; } void preen_block_files_max() { unsigned local_journal_size; if (block_files_max) return; /* default matching TI's code */ local_journal_size = ffs_sector_size >> 4; if (local_journal_size < 1024) local_journal_size = 1024; block_files_max = (local_journal_size >> 4) - 6; }