Topic/syslog#29
Conversation
| tqftpserv_srcs, | ||
| dependencies : [qrtr_dep, zstd_dep], | ||
| dependencies : [qrtr, zstd_dep], | ||
| c_args : ['-g', '-Wall', '-Werror', '-Wsign-compare', '-Wunused-parameter', '-Wtype-limits', '-Wimplicit-function-declaration'], |
There was a problem hiding this comment.
This is obviosly an abuse of dependencies and it might break for non-gcc compilers. Please use add_global_arguments to add build options.
There was a problem hiding this comment.
I added arguments using add_project_arguments
| } | ||
|
|
||
| if (tsize && *tsize != -1) { | ||
| if (tsize && *tsize != (size_t)-1) { |
| /* Header (4 bytes) + data size */ | ||
| send_len = 4 + response_size; | ||
| if (send_len > p - buf) { | ||
| if (send_len > (size_t)(p - buf)) { |
There was a problem hiding this comment.
changed send_len from size_t to ssize_t
| */ | ||
|
|
||
| /* For memfd_create */ | ||
| #define _GNU_SOURCE |
There was a problem hiding this comment.
Why? it was fine as is and it's not related to warnings
There was a problem hiding this comment.
This macro needs to be defined for asprintf function usage in translate.c, so I moved it to meson.build
There was a problem hiding this comment.
Please move it back and add another one in translate.c
| } | ||
|
|
||
| if (write(output_file_fd, decompressed_buffer, decompressed_size) != decompressed_size) { | ||
| if (write(output_file_fd, decompressed_buffer, decompressed_size) != (ssize_t)decompressed_size) { |
There was a problem hiding this comment.
Change decompressed_size to size_t or ssize_t.
There was a problem hiding this comment.
No, not done. I've asked to change its type to one of size_t types.
| * | ||
| * Return: Log facility constant on success, -1 on error | ||
| */ | ||
| int tqftp_parse_log_facility(const char *facility_str) |
There was a problem hiding this comment.
Always use daemon, no need to let it be logged as "uucp".
| * tqftp_log_init_with_config() - Initialize logging with custom configuration | ||
| * @config: Logging configuration structure | ||
| */ | ||
| void tqftp_log_init_with_config(struct tqftp_log_config *config) |
There was a problem hiding this comment.
I'd suggest using function calls instead of passing config around. I.e. set_min_level, use_console, etc.
There was a problem hiding this comment.
configuration file will allow to run the server on various linux flavors without changing the server code. I added configuration support for command line arguments as well, I will remove them and have server access paths only.
There was a problem hiding this comment.
Why? It's really easier to parse few command line options rather than having a config file parser.
There was a problem hiding this comment.
We can add command line option, if we want to change the paths (based on the build type, android, LE, Ubuntu, etc) then we have to modify service file (or equivalent) that starts the server and this service file needs to be created based on variant.
With configuration file as well it would be similar (multiple configuration files) however, config files can be modified in on the fly for debugging. There are other tuning parameters that needs to be introduced, so I thought configuration file would be better than adding too many command line arguments.
Lets discuss which is better.
There was a problem hiding this comment.
I've looked again at this. I think the config is an overkill. Likewise the multi-level logging system is a definite overkill for something as simple as tqftpserv. Our systems use journald, so everything gets logged to the journal. I don't see why you can't use that to capture all the logging messages.
There was a problem hiding this comment.
I agree, these patches just introduce flexibility for the sake of having flexibility - and all flexibility at once.
Please add flexibility where you need it, not everywhere for the sake of it.
| * | ||
| * Return: 0 on success, -1 on error | ||
| */ | ||
| int tqftp_config_load_file(struct tqftp_config *config, const char *filename) |
There was a problem hiding this comment.
Yikes. If you want to have a config file, use one of existing libraries. I'd recommend libconfig. Or just use command line options.
There was a problem hiding this comment.
I tried using libconfig and it is not available for all builds, does it make sense to copy libconfig in this project (I don't like this though)?
There was a problem hiding this comment.
No, it doesn't. What do you mean by it 'being not available for all builds'?
There was a problem hiding this comment.
'What do you mean by it 'being not available for all builds'?
I attempted to build on Android flavor and it failed, I did some experiments and understood that libconfig is present and it needed to be enabled from base config file. I have used libconfig and posted new change.
There was a problem hiding this comment.
I don't really care about Android. But if you need libconfig there, just port it to external/ or platform/ or something like that.
There was a problem hiding this comment.
Having command line argument and a configuration file offers great flexibility, but what is the purpose/benefit?
Please include in the commit message "why" this patch is wanted.
|
|
||
| /* Convenience macros for common logging patterns */ | ||
| #define TQFTP_LOG_ERROR(fmt, ...) TQFTP_LOG_ERR(fmt, ##__VA_ARGS__) | ||
| #define TQFTP_LOG_WARN(fmt, ...) TQFTP_LOG_WARNING(fmt, ##__VA_ARGS__) |
There was a problem hiding this comment.
Why do we need these duplicates? Select one style and use it.
| #define TQFTP_LOG_PERROR(msg) TQFTP_LOG_ERR("%s: %s", msg, strerror(errno)) | ||
|
|
||
| /* Macro to log system errors with custom format */ | ||
| #define TQFTP_LOG_ERRNO(fmt, ...) TQFTP_LOG_ERR(fmt ": %s", ##__VA_ARGS__, strerror(errno)) |
There was a problem hiding this comment.
Again, select one style instead of having two very similar ones.
…r issues Resolve multiple compilation issues triggered by -Wall and -Werror flags: - Multiple warnings in in zstd_decompress_file function in zstd-decompress.h. - Eliminate redefinition of zstd_decompress_file between zstd-decompress.h and zstd-decompress.c. - Address pointer type mismatch in tqftpserv.c by correcting char * vs uint8_t * assignment. - Resolve signedness comparison issues in tqftpserv.c for send_len and tsize checks. - Remove unused parameters argc and argv in main() function of tqftpserv.c. These changes ensure clean compilation and adherence to strict warning policies. Change-Id: I1539433ec5122e0e6fc3c8e0d02900a040bc21de Signed-off-by: Bhaskar Valaboju <quic_bhaskarv@quicinc.com>
Introduce a project-specific logging framework through syslog. Change-Id: Ie3399a58e9772f25979471cbf2f861ad1962d788 Signed-off-by: Bhaskar Valaboju <quic_bhaskarv@quicinc.com>
Integrate configuration management via config file and command-line arguments to customize server behavior. This allows runtime configuration of key filesystem paths including readonly_path, readwrite_path, firmware_base, updates_dir, and temp_dir. It also enables dynamic adjustment of the default log level, supporting flexible deployment across platforms like Linux and Android without requiring code changes. Change-Id: I788ce0eb1052f43872800bc0f2e0cc5d0a6b442b Signed-off-by: Bhaskar Valaboju <quic_bhaskarv@quicinc.com>
Integrate syslog-based logging into tqftpserv source files. Logging now leverages system-level facilities for consistent output and easier debugging. Signed-off-by: Bhaskar Valaboju <quic_bhaskarv@quicinc.com>
Integrate configuration management via config file and command-line arguments to customize server behavior. This allows runtime configuration of key filesystem paths including readonly_path, readwrite_path, firmware_base, updates_dir, and temp_dir. It also enables dynamic adjustment of the default log level, supporting flexible deployment across platforms like Linux and Android without requiring code changes. Signed-off-by: Bhaskar Valaboju <quic_bhaskarv@quicinc.com>
Provide a sample configuration file to support runtime customization of server paths and log level settings. Signed-off-by: Bhaskar Valaboju <quic_bhaskarv@quicinc.com>
4551b96 to
d2e90ce
Compare
|
I addressed all the comments, it took time to validate on all flavors. |
Integrate configuration management via config file and command-line arguments to customize server behavior. This allows runtime configuration of key filesystem paths including readonly_path, readwrite_path, firmware_base, updates_dir, and temp_dir. It also enables dynamic adjustment of the default log level, supporting flexible deployment across platforms like Linux and Android without requiring code changes. Change-Id: I788ce0eb1052f43872800bc0f2e0cc5d0a6b442b Signed-off-by: Bhaskar Valaboju <quic_bhaskarv@quicinc.com>
|
Gentle Remainder!!! |
|
Gentle Remainder !!! |
|
Gentle Remainder, @lumag |
| prefix = get_option('prefix') | ||
|
|
||
| # Add specific warning flags not covered by warning_level=3 | ||
| add_project_arguments('-Wsign-compare', '-Wunused-parameter', '-Wtype-limits', '-Wimplicit-function-declaration', language : 'c') |
There was a problem hiding this comment.
Why? Why did you select these flags?
| @@ -4,12 +4,16 @@ project('tqftpserv', | |||
| 'c', | |||
There was a problem hiding this comment.
Please drop Gerrit tags. We don't use Gerrit here.
| } | ||
|
|
||
| if (write(output_file_fd, decompressed_buffer, decompressed_size) != decompressed_size) { | ||
| if (write(output_file_fd, decompressed_buffer, decompressed_size) != (ssize_t)decompressed_size) { |
There was a problem hiding this comment.
No, not done. I've asked to change its type to one of size_t types.
| * tqftp_log_init_with_config() - Initialize logging with custom configuration | ||
| * @config: Logging configuration structure | ||
| */ | ||
| void tqftp_log_init_with_config(struct tqftp_log_config *config) |
There was a problem hiding this comment.
I've looked again at this. I think the config is an overkill. Likewise the multi-level logging system is a definite overkill for something as simple as tqftpserv. Our systems use journald, so everything gets logged to the journal. I don't see why you can't use that to capture all the logging messages.
| * | ||
| * Return: 0 on success, -1 on error | ||
| */ | ||
| int tqftp_config_load_file(struct tqftp_config *config, const char *filename) |
There was a problem hiding this comment.
I don't really care about Android. But if you need libconfig there, just port it to external/ or platform/ or something like that.
|
|
||
| while ((opt = getopt_long(argc, argv, "l:ch", long_options, NULL)) != -1) { | ||
| switch (opt) { | ||
| case 1001: /* --readonly-path */ |
There was a problem hiding this comment.
Yuck. Nope. Use a normal way - a short single-letter param.
There was a problem hiding this comment.
I think long-only formats are fine, but the need for a comment gives away the obvious benefit of having enums for the values.
What I don't know is why we need (or why we want) these new options and why they are part of a commit with the title "add config file support".
quic-bjorande
left a comment
There was a problem hiding this comment.
There are some concrete issues that needs to be addressed in tqftpserv, adding 706 lines of configuration flexibility does not seem to be the most pressing issue...
|
|
||
| while ((opt = getopt_long(argc, argv, "l:ch", long_options, NULL)) != -1) { | ||
| switch (opt) { | ||
| case 1001: /* --readonly-path */ |
There was a problem hiding this comment.
I think long-only formats are fine, but the need for a comment gives away the obvious benefit of having enums for the values.
What I don't know is why we need (or why we want) these new options and why they are part of a commit with the title "add config file support".
| * | ||
| * Return: 0 on success, -1 on error | ||
| */ | ||
| int tqftp_config_load_file(struct tqftp_config *config, const char *filename) |
There was a problem hiding this comment.
Having command line argument and a configuration file offers great flexibility, but what is the purpose/benefit?
Please include in the commit message "why" this patch is wanted.
| @@ -4,12 +4,16 @@ project('tqftpserv', | |||
| 'c', | |||
There was a problem hiding this comment.
This patch seems to have various interesting and useful changes lumped together in one patch, and as it's part of the same PR as everything else none of it can be merged without agreeing to it all...
Split things into multiple patches and if possible multiple PRs.
| @@ -0,0 +1,122 @@ | |||
| // SPDX-License-Identifier: BSD-3-Clause-Clear | |||
There was a problem hiding this comment.
The commit message fails to establish the problem this resolves.
| {"warning", LOG_WARNING}, | ||
| {"notice", LOG_NOTICE}, | ||
| {"info", LOG_INFO}, | ||
| {"debug", LOG_DEBUG}, |
There was a problem hiding this comment.
12 different log levels!? What?!
| config->log_config.min_level = LOG_INFO; | ||
| config->log_config.options = LOG_PID | LOG_CONS; | ||
| config->log_config.use_console = 0; | ||
| config->log_config.ident = "tqftpserv"; |
There was a problem hiding this comment.
But you already provided these default in the previous patch.
| len = pread(client->fd, p, client->blksize, offset); | ||
| if (len < 0) { | ||
| printf("[TQFTP] failed to read data\n"); | ||
| TQFTP_LOG_ERR("failed to read data"); |
There was a problem hiding this comment.
Please just call the function directly, so we can have this lowercase.
| if (ret == 1) { | ||
| /* Help was shown */ | ||
| return 0; | ||
| } else if (ret < 0) { |
There was a problem hiding this comment.
Both conditional arms here are generally handled by one entity, which just calls exit().
| @@ -16,6 +16,7 @@ | |||
| #include "list.h" | |||
There was a problem hiding this comment.
Avoid adding a number of patches that builds up a bunch of functionality and then just throw it all in the mix at the end. If this change causes an issue, the bug is in any of the patches leading up to this change.
Also avoid doing multiple things in the patch itself. The commit message quite clearly tells that this adds config file support. (It also adds command line arguments, setting log level and other things, but you need to read the full patch to learn that)
| "translate.c", | ||
| ], | ||
| shared_libs: ["libqrtr"], | ||
| shared_libs: ["libqrtr", "libconfig"], |
There was a problem hiding this comment.
This is the last change in the series. In patch 3 Dmitry suggested that you should use libconfig instead, you said it doesn't work on Android, but here you're adding a dependency on it.
So, commit message doesn't match content, and if this is necessary it clearly can't be the last change in the series - as it would break the build of previous commits.
Request to merge below changes: