Skip to content

Commit

Permalink
Windows strtol() seems to have an issue with large values, using 64bits
Browse files Browse the repository at this point in the history
seems to resolve it.
  • Loading branch information
Lars Pötter committed Dec 18, 2023
1 parent 197e90a commit 6aab639
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="217584702280927032" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="218556331835935032" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(TARGET): $(OBJECTS)
gcc -ggdb $^ $(LIBS) -o $@

elf2uf2.o: elf2uf2.c
gcc -ggdb -c $< -o $@
gcc -ggdb --pedantic -Wall -c $< -o $@

all: $(TARGET)
size elf2uf2
Expand Down
8 changes: 4 additions & 4 deletions elf2uf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static family allFamilies[] = {
};

static bool verbose = false;
static uint32_t fam_id = 0;
static uint64_t fam_id = 0;
static unsigned long int payload_size = 256;
static char* elf_name = NULL;
static char* uf2_name = NULL;
Expand Down Expand Up @@ -199,7 +199,7 @@ static void report_family(void)
return;
}
}
printf("creating UF2 file for the unknown family id 0x%08x\n", fam_id);
printf("creating UF2 file for the unknown family id 0x%08lx\n", fam_id);
}

static void print_all_families(void)
Expand Down Expand Up @@ -319,7 +319,7 @@ static int copy_data(FILE* elf_file)
UF2_Block.magicStart1 = 0x9E5D5157;
UF2_Block.magicEnd = 0x0AB16F30;
UF2_Block.flags = 0x00002000;
UF2_Block.fileSize = fam_id;
UF2_Block.fileSize = (uint32_t)(fam_id & 0xffffffff);
UF2_Block.payloadSize = payload_size;
UF2_Block.blockNo = 0;
UF2_Block.numBlocks = num;
Expand Down Expand Up @@ -448,7 +448,7 @@ static int parse_command_line_parameters(int argc, char *argv[])
break;

case 'f' :
fam_id = strtol(optarg, &test, 16);
fam_id = strtoll(optarg, &test, 16);
if('\0' == *test)
{
// OK
Expand Down

0 comments on commit 6aab639

Please sign in to comment.