aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* tools: nv_data-imei: autotools: fix missing headerDenis 'GNUtoo' Carikli2022-07-261-1/+1
| | | | | | | | | | | | | | | | | Without that fix, nv_data-imei compiles fine in git, but if we build from a tarball, nv_data-imei.h is missing from the tarball: $ make dist $ tar tf libsamsung-ipc-0.7.0.tar.xz | grep nv_data-imei libsamsung-ipc-0.7.0/tools/nv_data-imei.c which then results in a compilation failure: CC nv_data-imei.o nv_data-imei.c:39:10: fatal error: nv_data-imei.h: No such file or directory 39 | #include "nv_data-imei.h" | ^~~~~~~~~~~~~~~~ compilation terminated. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: PKGBUILD: use --enable-strict-cflagsDenis 'GNUtoo' Carikli2022-07-261-1/+1
| | | | | | | This should help us catch more issues as the PKGBUILD doesn't necessarily use the same compiler versions than in the guix.scm. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gprs: ipc_gprs_pdp_context_request_set_setup: fix truncated stringsDenis 'GNUtoo' Carikli2022-07-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix, when compiling libsamsung-ipc with --enable-strict-cflags, we have the following error: gprs.c: In function 'ipc_gprs_pdp_context_request_set_setup': gprs.c:59:17: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation] 59 | strncpy((char *) data->username, username, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | sizeof(data->username)); | ~~~~~~~~~~~~~~~~~~~~~~~ gprs.c:61:17: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation] 61 | strncpy((char *) data->password, password, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 62 | sizeof(data->password)); | ~~~~~~~~~~~~~~~~~~~~~~~ It comes from the fact that the size of the username and password fields are fixed (to 32) in include/gprs.h: struct ipc_gprs_pdp_context_request_set_data { unsigned char enable; unsigned char cid; unsigned char magic1[4]; unsigned char username[32]; unsigned char password[32]; unsigned char unknown[32]; unsigned char magic2; } __attribute__((__packed__)); The issue is that in ipc_gprs_pdp_context_request_set_setup we had the following code: int ipc_gprs_pdp_context_request_set_setup( struct ipc_gprs_pdp_context_request_set_data *data, unsigned char enable, unsigned char cid, const char *username, const char *password) { [...] strncpy((char *) data->username, username, sizeof(data->username)); strncpy((char *) data->password, password, sizeof(data->password)); [...] return 0; } And in the strcpy(3) manual we have: The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated. So if we have a username and/or password of 32 or more characters, the copied data will not be null terminated hence the warning. Since username and passwords fields are character array and not strings, and that the field is padded with zeros anyway we can use memcpy instead. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gprs: ipc_gprs_define_pdp_context_setup: fix truncated stringDenis 'GNUtoo' Carikli2022-07-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix, when compiling libsamsung-ipc with --enable-strict-cflags, we have the following error: gprs.c: In function 'ipc_gprs_define_pdp_context_setup': gprs.c:38:9: error: 'strncpy' specified bound 124 equals destination size [-Werror=stringop-truncation] 38 | strncpy((char *) data->apn, apn, sizeof(data->apn)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It comes from the fact that the size of data->apn is fixed (to 124) in include/gprs.h: struct ipc_gprs_define_pdp_context_data { unsigned char enable; unsigned char cid; unsigned char magic; unsigned char apn[124]; } __attribute__((__packed__)); The issue is that in ipc_gprs_define_pdp_context_setup we had the following code: int ipc_gprs_define_pdp_context_setup( struct ipc_gprs_define_pdp_context_data *data, unsigned char enable, unsigned char cid, const char *apn) { [...] strncpy((char *) data->apn, apn, sizeof(data->apn)); [...] return 0; } And in the strcpy(3) manual we have: The strncpy() function is similar, except that at most n bytes of src are copied. Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated. So if we have an apn of 124 or more characters, the copied data will not be null terminated hence the warning. Since apn is a character array and not a string, and that the field is padded with zeros anyway we can use memcpy instead. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: fix Emacs temporary filesDenis 'GNUtoo' Carikli2022-07-261-1/+1
| | | | | | | | | | | | | Without that change, Emacs temporary files appear as untracked files when running git status: Untracked files: (use "git add <file>..." to include in what will be committed) scripts/#guix.scm# This is because a dot('.') will not match "any character" but will instead match for dots in files names. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: fix missing files and build local-modules in guix.scmDenis 'GNUtoo' Carikli2022-07-262-33/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the commit 5f97bb60091a1c4d4335fd02eff2b01e27e7a881 ("tools: ipc-modem: Move log functions in their own file"), we added new files for ipc-modem. That commit was then tested with scripts/guix.scm, which at the time didn't build ipc-modem, so the issue slipped through the automatic tests. So in addition of adding back these missing files in Android.mk, this commit also makes guix.scm actually build all the local modules. This was not done before as it required some extensive work. That work consisted in adding code to retrieve the LOCAL_MODULEs from the Android.mk, and passing that to the package build and install procedures (which had to be converted into Guix's G-Expressions (gexp)[1] to be able to more cleanly get that data). In addition, making contributions to android-make-stub was needed as well. Having some of the parsing done in the guix.scm file instead of android-make-stub is needed because otherwise the android-make-stub design would probably need to be redone: android-make-stub consists of some Makefiles that are passed to make via -f, and that in turn these Makefiles include the Android.mk in the local directory. This doesn't make it possible to handle dependencies cleanly, as to do that, the Android.mk would need to first be parsed through another mean to understand the dependencies tree, and then to build the local modules in order. And that would need to be done in some compatible way not to break existing users of android-make-stub (like Guix that builds some Android packages with it). [1]https://guix.gnu.org/en/manual/devel/en/guix.html#G_002dExpressions Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* configure.ac: Add an option to use scripts/guix.scm's strict CFLAGSDenis 'GNUtoo' Carikli2022-07-228-16/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CFLAGS that are in the %common-strict-cflags in scripts/guix.scm have been validated with both GCC and CLANG and they are useful to find potential issues in the code or code that won't compile on Android. However while the scripts/guix.scm script is really useful to test commits once they are ready, it is less convenient to use it when fixing issues in commits that are still being worked on. This is because it is not as fast as building libsamsung-ipc directly because: - it requires a clean source directory to work (this can be done with make distclean) so we can't reuse the current build output - libsamsung-ipc source code is copied and built 5 times (in different configurations) As for the implementation, AM_CFLAGS was used instead of appending to the default CFLAGS as CFLAGS is meant to be a variable for users. The effect is that both are independent, so if users don't want strict CFLAGS, they would need to not use --enable-strict-cflags. And it was implemented as a shell script to at the same time: - Enable to have comments, and good formating of the flags. - Enable to share the cflags between guix.scm and the autotools. - Keep the complexity low to keep it working in most situations. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* modems: xmm626: xmm626_kernel_smdk4412_fmt_recv: order headers alphabeticallyDenis 'GNUtoo' Carikli2022-06-261-3/+5
| | | | | | This helps avoiding including twice the same header by accident. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc-modem: fix duplicated codeDenis 'GNUtoo' Carikli2022-06-261-5/+2
| | | | | | | | | | | If the following fails: data.client = ipc_client_create(IPC_CLIENT_TYPE_DUMMY); then we cannot use ipc_modem_log, but we can use printf instead. This bug was introduced in commit aa738074f34c ("tools: ipc-modem: convert to sysexits.h"). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: Fix unused result warningDenis 'GNUtoo' Carikli2022-06-261-1/+5
| | | | | | | | | | | | | | | Without that fix, when running the following commands: $ cd tools $ makepkg we have: ../../../tools/nv_data-imei.c: In function ‘write_imei’: ../../../tools/nv_data-imei.c:769:9: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 769 | asprintf(&md5_path, "%s.md5", nv_data_path); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* xmm626_kernel_smdk4412_gprs_get_iface: handle asprintf errorsDenis 'GNUtoo' Carikli2022-06-261-1/+7
| | | | | | | | | | | | | | | Without that fix we have the following warning: CC modems/xmm626/xmm626_kernel_smdk4412.lo ../../../samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c: In function 'xmm626_kernel_smdk4412_gprs_get_iface': ../../../samsung-ipc/modems/xmm626/xmm626_kernel_smdk4412.c:589:9: warning: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result] 589 | asprintf(&iface, "%s%d", XMM626_[...]_IFACE_PREFIX, cid - 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC modems/xmm626/xmm626_mipi.lo Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* aries_gprs_get_iface: handle asprintf errorsDenis 'GNUtoo' Carikli2022-06-261-1/+6
| | | | | | | | | | | | | Without that fix we have the following warning: ../../../samsung-ipc/devices/aries/aries.c: In function 'aries_gprs_get_iface': ../../../samsung-ipc/devices/aries/aries.c:826:9: warning: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result] 826 | asprintf(&iface, "%s%d", ARIES_GPRS_IFACE_PREFIX, cid - 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* crespo_gprs_get_iface: handle asprintf errorsDenis 'GNUtoo' Carikli2022-06-261-1/+6
| | | | | | | | | | | | | Without that fix we have the following warning: ../../../samsung-ipc/devices/crespo/crespo.c: In function 'crespo_gprs_get_iface': ../../../samsung-ipc/devices/crespo/crespo.c:587:9: warning: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result] 587 | asprintf(&iface, "%s%d", CRESPO_GPRS_IFACE_PREFIX, cid - 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* crespo_gprs_get_iface_single: handle asprintf errorsDenis 'GNUtoo' Carikli2022-06-261-4/+8
| | | | | | | | | | | | | Without that fix we have the following warning: ../../../samsung-ipc/devices/crespo/crespo.c: In function 'crespo_gprs_get_iface_single': ../../../samsung-ipc/devices/crespo/crespo.c:562:9: warning: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result] 562 | asprintf(&iface, "%s%d", CRESPO_GPRS_IFACE_PREFIX, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: test: remplace touch shell commandDenis 'GNUtoo' Carikli2022-06-261-4/+21
| | | | | | | | | | | | | | | Without that fix, we have the following warning: ../../../../samsung-ipc/tests/partitions/android.c: In function ‘create_dummy_modem_image’: [...] ../../../../samsung-ipc/tests/partitions/android.c:53:9: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | system("touch /tmp/libsamsung-ipc.[...]/modem.img"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CCLD libsamsung-ipc-test Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: test: remplace mkdir shell commandDenis 'GNUtoo' Carikli2022-06-261-2/+24
| | | | | | | | | | | | | | Without that fix, we have the following warning: CC partitions/android.o ../../../../samsung-ipc/tests/partitions/android.c: In function ‘create_dummy_modem_image’: ../../../../samsung-ipc/tests/partitions/android.c:52:9: warning: ignoring return value of ‘system’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 52 | system("mkdir -p /tmp/libsamsung-ipc.55f4731d2e11e85bd889/"); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Autotools: Add --enable-samsung-ipc-device=[DEVICE] optionDenis 'GNUtoo' Carikli2022-06-262-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the Android.mk we have the following: ifneq ($(TARGET_DEVICE),) libsamsung_local_cflags += -DIPC_DEVICE_NAME=\"$(ipc_device_name)\" endif # ifneq ($(TARGET_DEVICE),) This makes libsamsung-ipc assume that it runs on a specific device. It can for instance be useful to test libsamsung-ipc on a device very similar to one that is already supported, or during development. The issue is that, with autotools and without this patch, this feature is not easy to use as to force the i9300 device we would have to run configure in this way: ./configure CFLAGS='-DIPC_DEVICE_NAME=\"i9300\"' And we had no feedback that could indicate if it worked or not. Note that even now, the only feedback we have is the output of ./configure because the autodetection of the device is done in ipc_device_detect. And ipc_device_detect is called by ipc_transport_client_create which setups the ipc_client struct. And without a valid ipc_client struct, we cannot use ipc_client_log, so we can't print in ipc_device_detect. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* configure.ac: fix default debug CFLAGSDenis 'GNUtoo' Carikli2022-06-141-1/+1
| | | | | | | | | | Without that fix, ./configure --enable-debug doesn't change the default CFLAGS as it should. This bug was introduced in the commit 6d394a3f9629 ("Makefile.am: move -ggdb and -O0 CFLAGS to configure.ac"). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* configure.ac: print CFLAGSDenis 'GNUtoo' Carikli2022-06-141-0/+5
| | | | | | | | | | | Some ./configure options like --enable-valgrind-tests and --enable-debug do change the default CFLAGS. As CFLAGS is a variable reserved for the user, it is a good idea to tell the people building libsamsung-ipc that we are changing the CFLAGS defaults behind the scenes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: https-send-sms: handle http return codesDenis 'GNUtoo' Carikli2022-06-141-15/+43
| | | | | | This handles documented return codes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: https-send-sms: don't depend on CURLU_ALLOW_SPACEDenis 'GNUtoo' Carikli2022-06-142-22/+36
| | | | | | | | | | CURLU_ALLOW_SPACE is available since curl 7.78.0, and not using it could enable us to be compatible with curl 7.62.0. Since Replicant 11 has curl 7.67.0, this should enable to run https-send-sms on Replicant 11. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: Add tool to send SMS from a provider HTTPS interfaceDenis 'GNUtoo' Carikli2022-06-146-0/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This can then be used during automatic tests, but the downside is that for now this tool only works with one provider. The following symbols from (lib)curl (along with their corresponding minimal (lib)curl version) have been used: +------------------------+---------------------------+ | curl symbols | minimum (lib)curl version | +------------------------+---------------------------+ | CURL_HTTP_VERSION_2TLS | 7.47.0 | | CURLUPART_URL | 7.62.0 | | CURLUPART_QUERY | 7.62.0 | | CURLU_URLENCODE | 7.62.0 | | CURLU_APPENDQUERY | 7.62.0 | | CURLU | 7.62.0 | | CURLU_ALLOW_SPACE | 7.78.0 | +------------------------+---------------------------+ So we need to depend on curl 7.78.0. And we currently have the following curl version: +----------------------------+--------------------+------------+ | Distribution | (lib)curl version | Compatible | +----------------------------+--------------------+------------+ | Replicant 4.2 | Doesn't have curl | No | | Guix 6b9105e557 | 7.28.1 | No | | Trisquel 7 x86_64 | 7.35.0-1ubuntu2.20 | No | | Replicant 6 | 7.43.0 | No | | Debian stretch x86_64 | 7.52.1-5+deb9u10 | No | | Replicant 11 | 7.67.0 | No | | Parabola i686 (07/04/2022) | 7.79.0-3.0 | Yes | | Guix i686 (07/04/2022) | 7.79.1 | Yes | +----------------------------+--------------------+------------+ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* configure.ac: use AS_HELP_STRINGDenis 'GNUtoo' Carikli2022-06-141-3/+6
| | | | | | | This enables to break long lines and it also handles the formatting automatically. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: tools: add all tools and their test filesDenis 'GNUtoo' Carikli2022-06-141-4/+13
| | | | | | | | | With this patch, running the following command in a clean git tree: $ ./configure && make && make check $ git status doesn't show any untracked files or directories anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: Add forgotten files generated by the PKGBUILDDenis 'GNUtoo' Carikli2022-06-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Running makepkg in the scripts directory creates some packages and temporary directories. As these files and directories are not in gitignore, they appear in the list of untracked files and directories in git status. Note that as the PKGBUILD is also modified in the process: it retrieve the local libsamsung-ipc git revision and then updates the PKGBUILD with that information. For instance if locally we made some local commits and that we have the 113695fa7d455af5ff01457e5b8bb05591534711 git revision, the PKGBUILD will be modified as follows: -pkgver=0.3.1.r703.7c5e96a +pkgver=0.3.1.r743.113695f This enables to precisely track the git revision being used which is a good thing for development and testing (this PKGBUILD is meant for that) as users or developers can then know which version they are running. The issue is that if this modification is added to a git commit, then the revision changes again and the next time makepkg is run, the revision will change again. However as far as I know it's not really possible to fix that (without doing bruteforce computations) so the PKGBUILD will still end up in the list of untracked files in git status. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* gitignore: Add forgotten Valgrind log filesDenis 'GNUtoo' Carikli2022-06-141-0/+1
| | | | | | | | | | | | When running the tests with --enable-valgrind-tests, many valgrind.*.log files are produced in several directories. As the '*' is replaced by the pid of the process being monitored, over time the number of valgrind log files keep increasing at each 'make check' run, so without this patch, git status shows many valgrind.*.log in the list of untracked files. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: help: the phone number is mandatory when using --call=Denis 'GNUtoo' Carikli2022-05-231-1/+1
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: help: the pin code is mandatory when using --pin=Denis 'GNUtoo' Carikli2022-05-231-1/+1
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Move log functions in their own fileDenis 'GNUtoo' Carikli2022-05-235-66/+128
| | | | | | | | | | This has several advantages: - This makes the code cleaner as we now have a more abstract logging and less code in the main c file. - If new files are added, this will enable to use logging functions in the new files. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: Move ipc-modem in its own directoryDenis 'GNUtoo' Carikli2022-05-239-9/+23
| | | | | | This enables to then split ipc-modem in several files in a clean way. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Autotools: add support for Valgrind for checksDenis 'GNUtoo' Carikli2022-05-239-18/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables contributors to run Valgrind when running 'make check' for instance before sending patches. The --enable-valgrind option was used instead of using --enable-checking=valgrind like GCC uses as the code for that is much easier to get right. As Valgrind is very slow, I had to increase the timeouts in the ipc-modem tests. For now I settled on 60 seconds to have some margin for machines or setups that are potentially slower than the one I use. For the guix.scm, with Guix 1.3.0, Valgrind needs the ld.so .symtab to work, so as Valgrind doesn't know where to find them, so we had to use --extra-debuginfo-path for that. This is also why we pass '-v' to valgrind as it prints message explaining the issue when it doesn't find the required symbols. And we also needed a trick mentioned in the Guix mailing list[1] to find the right path for the debug information as the glibc being used by packages isn't exported publicly. [1]https://lists.gnu.org/archive/html/help-guix/2022-03/msg00036.html The proper fix will be merged in the next Guix release (merging it now is not possible since it would require to rebuild everything, and that is only possible with new releases). A temporary workaround with 4d1a88312cbebb10d47905d6d023953ac85bcd04 (gnu: valgrind: Allow ld.so symbols to be found.) was also merged in the current Guix so it is possible to get it with guix pull, but here it's probably better to stick with a workaround in the guix.scm for now as this also enables to use older guix revisions for testing. Thanks to the people on #guix on Liberachat for helping me to solve this Valgrind issue. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Makefile.am: move -ggdb and -O0 CFLAGS to configure.acDenis 'GNUtoo' Carikli2022-05-233-13/+17
| | | | | | | This makes sure that all the program and libraries being built have the same obtimization level and debug CFLAGS. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: guix.scm: use --enable-debugDenis 'GNUtoo' Carikli2022-05-231-1/+7
| | | | | | | | Replicant 6.0 is currently the main project using libsamsung-ipc and it uses --enable-debug to show the hexadecimal dump of the samsung-ipc packets, so it's a good idea to do compilation tests with it. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Makefile.am: Unify leading whitespaces in definitionsDenis 'GNUtoo' Carikli2022-05-231-4/+4
| | | | | | | | | In the definitions of all the other part of this Makefile.am and in all other Makefile.am, the leading whitespaces are tabs. This makes sure that AM_CFLAGS also use leading tabs. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* configure.ac: align --enable-debug helpDenis 'GNUtoo' Carikli2022-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix, the --enable-debug is missaligned with the other help that is around it: Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --enable-static[=PKGS] build static libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --enable-debug Enable debug build (default=disabled) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix]. --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: move the tests in their own directoryDenis 'GNUtoo' Carikli2022-03-284-3/+9
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: handle --call= and --call startDenis 'GNUtoo' Carikli2022-03-282-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without that fix with --call= it picks an empty string as the number: $ ipc-modem --debug --dry-run start --call= CC ipc-modem.o CCLD ipc-modem [I] Got call number! [I] Debug enabled [I] dry-run mode [1] Starting dummy modem_read_loop on FMT client [I] modem_dummy_read_loop: looping [...] and with --call start, it things that "start" is the number and fails because the "start" command is not found: $ ipc-modem --debug --dry-run --call start make: Nothing to be done for 'all'. [I] Got call number! Error: No command given. You need to use a command. See the help below for more details. usage: ipc-modem <command> commands: boot boot modem only power-on power on the modem only power-off power off the modem only start boot modem and start read loop arguments: --call=[NUMBER] call NUMBER --debug enable debug messages --dry-run Test the ipc-modem program without talking to the modem. --help print this help message --pin=[PIN] provide SIM card PIN With this fix it handles both situation by printing the right error: $ipc-modem --debug --dry-run start --call= make: Nothing to be done for 'all'. [E] Missing call number $ make ; ./ipc-modem --debug --dry-run --call start make: Nothing to be done for 'all'. [E] Missing call number Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: convert to sysexits.hDenis 'GNUtoo' Carikli2022-03-283-27/+60
| | | | | | | Using sysexits.h helps making testing easier by differentiating between different types of errors. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move command line parsing in its own functionDenis 'GNUtoo' Carikli2022-03-281-35/+51
| | | | | | | | This makes the code easier to read as the command line parsing code is quite big, and now it's not mixed in the main function anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of seq global variableDenis 'GNUtoo' Carikli2022-03-282-58/+64
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of state global variableDenis 'GNUtoo' Carikli2022-03-282-19/+20
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of out_call global variableDenis 'GNUtoo' Carikli2022-03-282-10/+11
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of call_done global variableDenis 'GNUtoo' Carikli2022-03-282-4/+3
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of in_call global variableDenis 'GNUtoo' Carikli2022-03-282-20/+21
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of sim_pin global variableDenis 'GNUtoo' Carikli2022-03-282-17/+18
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: get rid of call_number global variableDenis 'GNUtoo' Carikli2022-03-282-22/+23
| | | | | | | Since we now have a private struct for all the data we need, we don't need to use global variables anymore. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: move ipc_client struct in private data structDenis 'GNUtoo' Carikli2022-03-282-55/+53
| | | | | | | Having everything needed in the same struct will simplify the code later on as we could also move the global variables there as well. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: Add syslog supportDenis 'GNUtoo' Carikli2022-03-282-20/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is ongoing work to make libsamsung-ipc and the modem drivers of the Galaxy SIII (GT-I9300) work on top of an upstream kernel instead of kernels derived from the vendor kernels. For that work it's convenient to be able to store the kernel the kernel logs in systemd-journald along with the output of ipc-modem. If the kernel is built with CONFIG_LOCALVERSION_AUTO, we can track the exact kernel revision used. And if the modem driver crashed, we can still have the logs in journald at the next reboot. It also enables us to store logs over a long period of time and get back to old logs. However when running ipc-modem through a systemd service unit, the output is piped to systemd, and we only get the following output with journalctl -u <service> .service: Started [Service Unit Description]. This is because when a program is piped, line buffering changes from line buffered (the default when outputing to stdout on a terminal according to setbuf(3)) to fully buffered. To fix that we add a syslog log-target. Several programs already have a --syslog (like OpenVPN) or --log-target= (like PulseAudio) command line argument. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: use the log callback instead of printfDenis 'GNUtoo' Carikli2022-03-282-86/+173
| | | | | | | | | | This enables to add other log callbacks than printf / stdout later on. The ipc_modem_log function is inspired from ipc_client_log. This change should contain no functional changes. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: group contiguous printf callsDenis 'GNUtoo' Carikli2022-03-281-17/+17
| | | | | | | | | | | | There is no use in making multiple calls to printf when only one call is sufficient. It's also a good practice to do that in general, especially when part of the code can print to the console at any time, to ensure that that all the buffer is printed contiguously and not interleaved with other prints. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>