aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* tools: ipc-modem: Add testsHEADreplicant-6.0-0004-transitionreplicant-6.0-0004-rc6replicant-6.0-0004masterDenis 'GNUtoo' Carikli2021-09-013-2/+85
| | | | | | | While the tests don't talk to a real modem, they are still useful to detect regressions with the use of threads. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add dry-run mode for automatic testingDenis 'GNUtoo' Carikli2021-09-011-2/+41
| | | | | | | | This enables to test things like the threads usage without the need for a real modem implementing the samsung-ipc protocol. This could for instance be used in libsamsung-ipc automated tests. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move command line options prints in its own functionDenis 'GNUtoo' Carikli2021-09-011-1/+9
| | | | | | | As this is done once all options have been parsed, it enables to only print some options when debug is on. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move parsed command line arguments in a structDenis 'GNUtoo' Carikli2021-09-011-12/+22
| | | | | | | | This enables to more easily enables to share the parsed command line arguments across different functions and it also enables to add new command line arguments more easily. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Fail if there is no chosen commandDenis 'GNUtoo' Carikli2021-09-011-1/+11
| | | | | | | | | | | | | | | Without that fix, if some arguments were set and no command was given, ipc-modem would proceed anyway: $ ./tools/ipc-modem --debug [I] Debug enabled [...] As it's expected to at least be used with a command to do something meaningful, without that fix, it could misslead users into thinking that everything is fine when it's not or vice versa. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move ipc code outside of mainDenis 'GNUtoo' Carikli2021-09-011-48/+83
| | | | | | | | | | This makes the code easier to read as we separate the command line handling from the IPC code. In addition it also enables to more easily add RFS support later on as the IPC code is not mixed with command line handling. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add --help in the helpDenis 'GNUtoo' Carikli2021-09-011-0/+1
| | | | | | | While --help is parsed in the command line, it wasn't described in the help itself. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: small code cleanups for the command line interfaceDenis 'GNUtoo' Carikli2021-09-011-30/+30
| | | | | | | | The help and the code is sorted alphabetically. It should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add ipc_client_type_stringDenis 'GNUtoo' Carikli2021-09-013-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | When working on applications using libsamsung-ipc, we sometimes have functions that have an ipc client type argument and that work for all 3 ipc client types, or want to refactorize the code to do that in order to make the code more clean and generic. However in these cases, these functions often needed to output some error message or tell users what is going on through logging prints, and the code ends up being way cleaner if there is a generic function to get the name of the ipc client type. In many cases it makes sense not to use the full IPC_CLIENT_TYPE_<type> name but only the <name> type in these messages, so because it's easier to add IPC_CLIENT_TYPE_ to the <type> than removing it, it makes sense to only return the string associated to the type (like "FMT", "RFS" or "DUMMY". The least significant number of the library version was also bumped as we are adding a new function, but the applications that were built against older libsamsung-ipc revisions should still work. However applications that depends on this ipc_client_type_string will not work with previous versions of libsamsung-ipc. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Move string functions in their own fileDenis 'GNUtoo' Carikli2021-09-014-366/+391
| | | | | | | | | | | There are already 4 string functions and combined together, they already take more than 300 lines, so it makes sense to move them in a separate file. In addition, it will also clarify in which files new string functions are supposed to be added in. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: Add static ipc-modem for drop-in testsDenis 'GNUtoo' Carikli2021-09-011-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Replicant 6.0, ipc-modem is shipped in the images. When it will make it in released images, it will be very useful for regression testing and for tests that don't involve the full Android stack[1]. For such tests to work, users are expected to disable the modem (with 'modem.sh off') before. In this configuration, the test utilities like ipc-modem use the system libsamsung-ipc as they are linked dynamically against it. However if we want to also do regression testing with code that is being worked on, it's very convenient to build test utilities that have libsamsung-ipc built-in: This way it can test our the code that is being worked on without interfering in any way with the Android stack. The static version of ipc-modem can for instance be built with the following commands in the Replicant source code directory: $ source build/envsetup.sh $ lunch replicant_i9300-userdebug $ make ipc-modem-static It can then be run with the following commands (for the GT-I9300): $ adb root $ adb remount $ adb push \ out/target/product/i9300/system/bin/ipc-modem-static \ /system/bin/ $ adb shell "modem.sh off" $ adb wait-for-device $ adb root $ adb shell ipc-modem-static [...] Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: add forgotten test filesDenis 'GNUtoo' Carikli2021-09-011-0/+12
| | | | | | | | | | | Running tests (and even just running autogen.sh) produces files used during the tests, and so git has to ignore these as they are produced during the build procedure. Ideally they should have been added to gitignore when I added the tests that generated these files but I forgot. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: Add forgetten nv_data-imeiDenis 'GNUtoo' Carikli2021-09-011-0/+1
| | | | | | | Without this patch, after compiling libsamsung-ipc, git status shows tools/nv_data-imei in the list of untracked files. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: Also ignore Emacs and Vim swap filesDenis 'GNUtoo' Carikli2021-09-011-0/+4
| | | | | | | | | | | Text editors produce temporary files. They can often be used to recover data in case of computer crash or abrupt shut down. However when using text editors like Emacs and Vim, temporary files often end up in the source directory, so as they are not part of the official libsamsung-ipc source code we need to tell git to ignore them. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: fix nv-data-md5 compilation with Replicant 6replicant-6.0-0004-rc5-transitionreplicant-6.0-0004-rc5Denis 'GNUtoo' Carikli2021-03-172-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | When compiling nv-data-md5 under Replicant 6 we have: hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c: In function 'main': hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c:103:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1: some warnings being treated as errors So we simply need to add a return in the error path. While we're at it, we use an exit code referenced in sysexits.h to follow a standard. This can help differentiating between different types of errors. Thanks to that, it can also simplify the code when writing tests. As Android doesn't have sysexits.h, we also need to use the one that has been copied inside libsamsung-ipc in tools/include/glibc, else it would also fail to compile because of the missing header file. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: add option to call a numberDenis 'GNUtoo' Carikli2021-03-171-10/+27
| | | | | | | | | | | | | | | The ipc-modem tool contained commented code to call a specific phone number. This patch reuses that code and retrieve the number to call from the command line. The number to call is expected to be in the same country as the caller SIM card and network. Adding support for international calls could be done by computing the right prefix instead of hardcoding the IPC_CALL_PREFIX_NONE prefix. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: fix potential out of bounds sim_pin memcpyDenis 'GNUtoo' Carikli2021-03-171-11/+12
| | | | | | | | | | If for instance "1234" is given as pin, the size of optarg should be 5 but memcpy would copy 8. In addition, the current code also makes sure that there is a terminating null byte ('\0') inside the sim_pin array. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: remove unused DEF_SIM_PIN definitionDenis 'GNUtoo' Carikli2021-03-171-1/+0
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: Add open_android_modem_partition_by_nameDenis 'GNUtoo' Carikli2021-03-042-0/+65
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Partitions: android: add tests for open_android_modem_partitionDenis 'GNUtoo' Carikli2021-03-048-3/+366
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Libraries typically have a public API and some internal implementation of that API. In libsamsung-ipc, the public API is defined in the include/ directory from the top directory. When compiling and installing libsamsung-ipc, that include/ directory is installed as well. Anything that is not defined in include/ is not part of that public API. However here we need to precisely test functions that are not part of that public API: The open_android_modem_partition function being tested here is only used by the herolte device, and that device doesn't have a battery that is easily replaceable, so most Replicant contributors will not want to get that device. As currently all the non static symbols of libsamsung-ipc are exported and that open_android_modem_partition isn't static, we can simply link to libsamsung-ipc for now and use its internal headers to access the functions to test. If at some point, libsamsung-ipc only exports the symbols defined in include/ we would need to find other ways to run such tests, for instance by using test frameworks that take care of that or by compiling libsamsung-ipc source code into the test programs. Some of the code of the libsamsung-ipc-test utility was adapted from code from the nv_data-md5 utility (which is currently in tools/). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: move Android partition handling in its own directoryDenis 'GNUtoo' Carikli2021-03-035-25/+88
| | | | | | | This code could also be useful for other devices and in any cases it's not device specific. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* MAINTAINERS: Update git URLDenis 'GNUtoo' Carikli2021-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | While libsamsung-ipc is not limited to Replicant (it can be used on GNU/Linux or in other Android distributions), it is currently maintained by Replicant. In order to make that more clear, it was renamed by the commit aa4f61805b2d8943e94847cae825ec209060569e ("Move libsamsung-ril and libsamsung-ipc in vendor/replicant") in the Replicant manifest repository[1]. Because of that we also need to adjust the git URL in the MAINTAINERS file. In addition we use https because it's safer than git:// as it uses TLS, and because we have redirects in place for http(s) but not for git://, so if the repository URL changes again, the old URL will most likely continue to work with http(s). [1]https://git.replicant.us/replicant/manifest.git Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: move TOC handling in its own directoryDenis 'GNUtoo' Carikli2021-02-286-33/+93
| | | | | | This could enable other devices to use the TOC handling functions. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc/Makefile.am: split it in subdirectoriesDenis 'GNUtoo' Carikli2021-02-283-36/+43
| | | | | | | | | The samsung-ipc/Makefile.am became pretty big. Because of that, it's It's better to split it to have one Makefile.am per subdirectory. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: Add support for Android 11Denis 'GNUtoo' Carikli2021-02-282-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we configure Replicant 11, libsamsung-ipc and libsamsung-ril to have both libraries in /system/lib/, tools work fine on the Galaxy SIII (GT-I9300): # find -name libsamsung-ril.so 2>/dev/null ./system/lib/libsamsung-ril.so # find -name libsamsung-ipc.so 2>/dev/null ./system/lib/libsamsung-ipc.so # find -name nv_data-md5 2>/dev/null ./system/bin/nv_data-md5 # nv_data-md5 Usage: nv_data-md5 [nv_data.bin] And libsamsung-ril tries to load libsamsung-ipc from the right location in /system/lib/, but it fails due to the vendor and system separation: 01-14 15:50:57.739 1475 1475 E RILD : dlopen failed: dlopen failed: library "/system/lib/libsamsung-ril.so" needed or dlopened by "/system/vendor/bin/hw/rild" is not accessible for the namespace "(default)" Adding LOCAL_PROPRIETARY_MODULE fixes that. Note that the name of that property can be misleading here: libsamsung-ipc is free software and shall remain free software. Instead we need to understand LOCAL_PROPRIETARY_MODULE as a way to tell the Android build system that libsamsung-ipc is not part of the base Android code but instead that it is code that is specific to a device, set of devices and/or Android distribution. LOCAL_MODULE_RELATIVE_PATH cannot be used instead: even if the binaies end up in /vendor/bin/hw/, and that the libraries ends up in /vendor/lib/hw/, for some reasons the libraries can't be found: i9300:/ # /system/vendor/bin/hw/nv_data-md5 CANNOT LINK EXECUTABLE "/system/vendor/bin/hw/nv_data-md5": library "libsamsung-ipc.so" not found: needed by main executable And most importantly, rild has the same issue than before: E RILD : dlopen failed: dlopen failed: library "libsamsung-ipc.so" not found: needed by /system/vendor/lib/hw/libsamsung-ril.so in namespace (default) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Initial support for herolte (Samsung Galaxy S7 GSM).Tony Garnock-Jones2021-02-226-0/+717
| | | | | | | | | | | | | | | | | | | | | | | | | | A previous version of this patch was tested on the herolte, however since then, several light functional changes were introduced. With the previous patch, it was possible to boot the modem and it was probably possible to send message to, and receive messages from the modem. For the TARGET_DEVICE we use in our Android.mk, In the Android.mk of android_device_samsung_herolte[1] we have: ifneq ($(filter herolte, $(TARGET_DEVICE)),) include $(call all-makefiles-under,$(LOCAL_PATH)) endif so we can safely assume that the TARGET_DEVICE is herolte. [1]https://github.com/LineageOS/android_device_samsung_herolte Signed-off-by: Tony Garnock-Jones <tonyg@leastfixedpoint.com> GNUtoo: rebased, code cleanup, more debug prints, commit message content but not its summary. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: order libsamsung_ipc_local_src_files alphabeticallyDenis 'GNUtoo' Carikli2021-02-221-19/+19
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: order target devices alphabeticallyDenis 'GNUtoo' Carikli2021-02-221-12/+12
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc/utils: add data_read and data_writeDenis 'GNUtoo' Carikli2021-02-162-0/+46
| | | | | | | | | | | | | | These wrappers are meant to handle the case where read or writes handles a smaller number of bytes than requested. This way that handling doesn't need to be duplicated everywhere in libsamsung-ipc. Having access to the ipc_client struct could enable future logging of read and writes without having to change any of the code already using data_read and data_write. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: handle list-supported in a more generic wayDenis 'GNUtoo' Carikli2021-02-131-48/+48
| | | | | | | Before that, the command infrastructure wasn't used for list-supported which led to more manual parsing and more code. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: fix crash with commands options without commandDenis 'GNUtoo' Carikli2021-02-111-3/+4
| | | | | | | | | | | Without that fix command can be NULL when it reaches this assert: assert(command->options & OPTION_FILE); The crash can be reproduced by running nv_data-imei with command options but without the command itself, for example with 'nv_data-imei -i 1'. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: main: Fix uninitialized command and command_option structsDenis 'GNUtoo' Carikli2021-02-111-2/+2
| | | | | | | | | | | | This was spotted by compiling nv_data-imei on Replicant 6: it gave the following warning: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:1062:15: warning: 'command' may be used uninitialized in this function [-Wmaybe-uninitialized] rc = command->func(nv_data_path, &offset); ^ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: Fix return-type compilation errors on Replicant 6.0Denis 'GNUtoo' Carikli2021-02-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Replicant 6.0 we have: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c: In function 'main': hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:1064:1: error: control reaches end of non-void function [-Werror=return-type] In nv_data-imei's main we had: int main(int argc, char * const argv[]) { [...] assert(false); } and for some reasons the Replicant 6.0 toolchain[1] doesn't recognize that adding a 'return 0;' won't change anything, however doing that is harmless and fixes that compilation error. This issue also affected errno_to_sysexit in the same way: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c: In function 'errno_to_sysexit': hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:837:1: error: control reaches end of non-void function [-Werror=return-type] [1] The compiler used (which is built by vendor/replicant/build-toolchain) returns the following when run with --version: arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: guix.scm: Add Replicant 6 TARGET_ERROR_FLAGSDenis 'GNUtoo' Carikli2021-02-101-5/+12
| | | | | | | | | | | | The TARGET_ERROR_FLAGS are available from build/core/config.mk in Replicant 6. -Werror=non-virtual-dtor was only added to CLANG because it fails to be recognized with GCC: cc1: error: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C [-Werror] Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: guix.scm: Add Replicant 6 COMMON_GLOBAL_CFLAGSDenis 'GNUtoo' Carikli2021-02-101-0/+3
| | | | | | | The COMMON_GLOBAL_CFLAGS are available from build/core/config.mk in Replicant 6. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: get rid of "pointer of type 'void *' used in subtraction"Denis 'GNUtoo' Carikli2021-02-101-3/+3
| | | | | | | | | | | | | When building nv_data-imei in Replicant 6 we have: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c: In function 'bruteforce_imei_offset': hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:675:18: warning: pointer of type 'void *' used in subtraction [-Wpointer-arith] (ptr - buffer), ^ Using a data type with a known size like char* avoids this error. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: guix.scm: reorder CLFAGSDenis 'GNUtoo' Carikli2021-02-101-1/+8
| | | | | | This enables to more easily add new flags. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add sysexits.h for AndroidDenis 'GNUtoo' Carikli2021-02-102-1/+115
| | | | | | | | | | | | | | | | | | | | | The include has been imported from sysexits.h from Parabola i686. As Replicant 6 and Replicant 11 don't have sysexits.h, the compilation of nv_data-imei will fail if it's not provided somehow: hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:32:22: fatal error: sysexits.h: No such file or directory #include <sysexits.h> ^ compilation terminated. Being able to use sysexits.h is really interesting as it provides a standard for applications exit codes. In turn it enables to design tests that are more fine grained and to avoid too messy test code while doing that, simply by following this standard. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: guix.scm: use latest clangDenis 'GNUtoo' Carikli2021-02-101-2/+2
| | | | | | | | | | | | | | Without that, it will end up using clang-10 while we now have clang-11. This will make Guix build clang-10 which is time consuming. Instead by using the latest clang we can use binary packages (Guix calls that substitutes) of clang which speeds up the build of libsamsung-ipc a lot, since most of the time we don't need to build any dependencies. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc_utils: add ipc_group_stringDenis 'GNUtoo' Carikli2021-02-012-0/+51
| | | | | | | | | | | | | While ipc_group_string is not used by libsamsung-ipc (yet), it's still a good idea to add it as tools and applications using libsamsung-ipc can then use it to display the group of a command. It's also a better idea to have it in libsamsung-ipc than in each tool using it as libsamsung-ipc centralizes the knowledge about the samsung-ipc protocol, so if new groups appear at some point, the ipc_group_string function could be updated along the way. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* include: samsung-ipc.h: fix missing off_t definitionDenis 'GNUtoo' Carikli2021-02-011-0/+1
| | | | | | | | | | Including samsung-ipc.h in a file without other includes results in a compilation error: .../include/samsung-ipc.h:161:1: error: unknown type name ‘off_t’ 161 | off_t file_data_size(struct ipc_client *client, [...] | ^~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* include: samsung-ipc.h: fix missing size_t definitionDenis 'GNUtoo' Carikli2021-02-011-0/+2
| | | | | | | | | | | | | | | | | | | Including samsung-ipc.h in a file without other includes results in a compilation error: .../include/samsung-ipc.h:51:2: error: unknown type name ‘size_t’ 51 | size_t size; | ^~~~~~ .../include/samsung-ipc.h:77:7: error: unknown type name ‘size_t’ 77 | size_t size), | ^~~~~~ .../include/samsung-ipc.h:26:1: note: ‘size_t’ is defined in header ‘<stddef.h>’; did you forget to ‘#include <stddef.h>’? 25 | #include <sys/time.h> +++ |+#include <stddef.h> 26 | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* include: samsung-ipc.h: move include inside the #ifdef/#endif guardsDenis 'GNUtoo' Carikli2021-02-011-2/+2
| | | | | | | | | | | | | | | | | This separates more what is part of the header and what is not so things are more clear to the people reading the code. In addition, having all includes statements inside the #ifdef #endif header guards avoids issues with the inclusion of headers that are missing such guards. This can happen with headers imported from vendor kernels. So while headers imported from vendor kernels are typically not included in the headers exported by libsamsung-ipc, it's still good to have a consistent code style between exported and non exported headers. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Move guix.scm to scriptsDenis 'GNUtoo' Carikli2021-01-111-6/+7
| | | | | | | | | | | | | | | | | The scripts directory already has several scripts that are not needed to use libsamsung-ipc, but all of them are (or were) useful to work on patches for libsamsung-ipc. As this also applies to the guix.scm and that scheme is a scripting language, it would be more clear to have it moved in the scripts directory. In addition it could also make it more simple for distributions to not ship these files if they aren't interested in having them and/or if they only want files compatibles with the license currently used by libsamsung-ipc (GPLv2 or later). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc_nv_data_md5_calculate: handle size mismatch betterreplicant-6.0-0004-rc4Denis 'GNUtoo' Carikli2020-12-032-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently libsamsung-ipc assumes that the size of nv_data.bin files are always 0x200000. While it's supposed to be the case for all the devices we support, it is still a good idea to make sure that a meaningful error message is reported to the users of nv_data-md5. For instance if we created an empty file of 1 kB with the following command: $ ddrescue -s 1k /dev/zero zero.img and that we used nv_data-md5 on it: $ ./tools/nv_data-md5 zero.img [ipc] file_data_read: Error: rc < 0 [ipc] ipc_nv_data_md5_calculate failed: data is NULL Calculating nv_data backup md5 failed we had a completely meaningless error message. With this patch the error message looks like that instead: $ ./tools/nv_data-md5 zero.img [ipc] ipc_nv_data_md5_calculate: Checking zero.img size failed: requested size: 2097152, file size: 1000 Calculating nv_data backup md5 failed Here users have at least a fighting chance of being able to understand what is going wrong. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-md5: Add testsDenis 'GNUtoo' Carikli2020-12-032-2/+73
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add guix.scmDenis 'GNUtoo' Carikli2020-12-031-0/+214
| | | | | | | | | | | | | | | | | | | The guix.scm file can be used to test the build in various configurations in a reproducible way. Once you have guix installed, and up to date, you can use it with the following command: $ guix build --file=guix.scm The filename (guix.scm) is a convention that is also used in other packages to also do build tests in various configurations. For more background on the use of guix.scm see the Guix days 2020 presentation about it[1]. [1]https://xana.lepiller.eu/guix-days-2020/guix-days-2020-efraim-flashner-build-it-with-guix.webm Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: fix unused-labelDenis 'GNUtoo' Carikli2020-12-031-1/+0
| | | | | | | | | | | | | | Without that fix, when building libsamsung-ipc under GNU/Linux with the "-Werror -W -Wall -Wunused -Wunused-function" CFLAGS, GCC and the autotools build system, we have: nv_data-imei.c: In function ‘bruteforce_imei_offset’: nv_data-imei.c:695:1: error: label ‘complete’ defined but not used [-Werror=unused-label] complete: ^~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Reviewed-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
* samsung-ipc: rfs: fix incorrect sign comparison for md5 file lengthJoonas Kylmälä2020-12-031-3/+5
| | | | | | | | | | | | | | | | | | When compiling with warnings (-Werror -W -Wall -Wunused -Wunused-function) enabled we get: rfs.c: In function ‘ipc_nv_data_md5_path_check’: rfs.c:115:17: error: comparison of integer expressions of different signedness: ‘__off_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare] if (st.st_size < 2 * sizeof(char) * MD5_DIGEST_LENGTH) { ^ This simplifies the comparison by making sure we have exactly 32 bytes (2*MD5_DIGEST_LENGTH, i.e. md5 digest in ascii) in the file we read the MD5 digest from. Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Tested-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Acked-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* checkpatch: ignore files added, moved, deleted warningDenis 'GNUtoo' Carikli2020-11-261-0/+7
| | | | | | | | | | | | | | Without that patch we always have the following warning when adding, moving, or deleting files when using checkpatch.pl: WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #93: new file mode 100644 Since we have only one maintainer for now, we can safely ignore that warning and add it back as soon as we have a second co-maintainer on board. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>