Just to add, OpenWRT has some pretty extreme optimization flags in GCC to make the code as small as possible.
Some years ago a dev i was talking to that was working on arduino was doing similar optimizations to the compile process for his programs, and even found some GCC bugs doing those optimizations, apart from 1000 crashes in his code for no “apparent” reason.

@jolouis is totally right, if you make a program for say ubuntu, you can’t expect it to work exactly the same on openwrt due to the optimizations of gcc, glibc and all the surrounding libraries. Test the USB using some tools that are confirmed to work that ship or are present in openwrt, then compare to your program.