Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code refactoring #1298

Merged
merged 10 commits into from
Feb 27, 2018
Merged

code refactoring #1298

merged 10 commits into from
Feb 27, 2018

Conversation

sunghan-chang
Copy link
Contributor

  1. Some module which uses file operation APIs like open, read, write and so on make a dependancy with NFILE_DESCRIPTORS to prevent compilation and linking errors.
  2. TASH adds new config, TASH_SCRIPT to disable script functionality.

The cle is "EMACS-like Command Line Editor", not VI work-alike.
This commit is come from Nuttx commit 6e46290.
The cle uses FILE type of argument but that type is valid
when NFILE_STREAMS is bigger than 0.
This commit makes a dependancy with NFILE_STREAMS to CLE.

CC:  cle.c
cle.c: In function 'cle':
cle.c:861:22: error: dereferencing pointer to incomplete type
  priv.infd = instream->fs_fd;
                      ^
cle.c:862:24: error: dereferencing pointer to incomplete type
  priv.outfd = outstream->fs_fd;
                        ^
make[2]: *** [cle.o] Error 1
The standard I/Os, stdin, stdout and stderr, use the sched_getstreams
function but it is in "#if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0"
conditional. Some combination of config does not enable them so that
it causes compilation errors as shown below:

CC:  vi.c
In file included from vi.c:66:0:
vi.c: In function 'vi_write':
vi.c:513:13: error: invalid type argument of '->' (have 'int')
     fprintf(stderr, "ERROR: write to stdout failed: %d\n", errcode);
             ^
...
vi.c:3432:11: error: invalid type argument of '->' (have 'int')
   fprintf(stderr, "ERROR: Too many arguments\n");
           ^
make[2]: *** [vi.o] Error 1

Because there is no way to use standard I/Os without those configs,
this commit makes I/Os NULL under undefined those configs.
1. The ioctl has last argument with unsigned long type. But dm gives
   it as void *. This commit fixs below:

CC:  src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c
src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c: In function 'dm_conn_get_address':
src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c:203:29: error: passing argument 3 of 'ioctl' makes integer from pointer without a cast [-Werror]
  if (ioctl(fd, SIOCGIFCONF, (void *)&ifcfg) < 0) {
                             ^
In file included from src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c:33:0:
/home/sunghan/Work/TinyAra/TizenRT_forked/os/include/sys/ioctl.h:140:5: note: expected 'long unsigned int' but argument is of type 'void *'
 int ioctl(int fd, int req, unsigned long arg);
     ^
src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c: In function 'dm_conn_get_interface':
src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c:246:29: error: passing argument 3 of 'ioctl' makes integer from pointer without a cast [-Werror]
  if (ioctl(fd, SIOCGIFCONF, (void *)&ifcfg) < 0) {
                             ^
In file included from src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c:33:0:
/home/sunghan/Work/TinyAra/TizenRT_forked/os/include/sys/ioctl.h:140:5: note: expected 'long unsigned int' but argument is of type 'void *'
 int ioctl(int fd, int req, unsigned long arg);
     ^
cc1: all warnings being treated as errors
make[1]: *** [s5j_dm_connectivity.o] Error 1

2. That file uses slsi wifi APIs and there is no dependancy with s5j arch
  so that a conditional in Make.defs should be changed.
  This commit fixs below linking error on some config combination as well:

/os/../build/output/libraries/libframework.a(s5j_dm_connectivity.o): In function `dm_cb_register_init':
/framework/src/dm/arch/sidk_s5jt200/s5j_dm_connectivity.c:104: undefined reference to `WiFiRegisterLinkCallback'
…automount functionalities

1. ARTIK05X_AUTOMOUNT and SIDK_S5JT200_AUTOMOUNT use mtd functionality and mtd is in FILE_DESCRIPTORS
  conditional. So, they should have a dependancy with NFILE_DESCRIPTORS.
  This commit fixs below:
/os/arch/arm/src/board/libboard.a(artik05x_tash.o): In function `artik05x_configure_partitions':
/os/arch/arm/src/artik05x/src/artik05x_tash.c:132: undefined reference to `progmem_initialize'
/os/arch/arm/src/artik05x/src/artik05x_tash.c:171: undefined reference to `ftl_initialize'
/os/arch/arm/src/artik05x/src/artik05x_tash.c:200: undefined reference to `mtd_setpartitionname'
/os/arch/arm/src/artik05x/src/artik05x_tash.c:162: undefined reference to `mtd_partition'
/os/arch/arm/src/artik05x/src/artik05x_tash.c:178: undefined reference to `mtdconfig_register'
/os/arch/arm/src/artik05x/src/artik05x_tash.c:186: undefined reference to `smart_initialize'

2. Some automount functionality is in board_app_initialize without any conditional.
  But that uses mount function and mount is controled by configuration.
  When mount is not enabled, automount functionality should not work.
  This commit covers them with AUTOMOUNT config and fixs below:
/os/arch/arm/src/board/libboard.a(artik05x_tash.o): In function `board_app_initialize':
/os/arch/arm/src/artik05x/src/artik05x_tash.c:331: undefined reference to `mount'

3. RTC driver uses file operation so that NFILE_DESCRIPTORS should be enabled.
  This commit makes a dependancy RTC with that and fix below:
/os/arch/arm/src/artik05x/src/artik05x_tash.c:378: undefined reference to `rtc_initialize'
…TORS

Vi uses file operation APIs like fopen, fread, stat and so on so that
it should have dependancies with them.
This commit fixs below linking errors:
/os/../build/output/libraries/libapps.a(vi.o): In function `vi_insertfile':
/apps/system/vi/vi.c:1113: undefined reference to `stat'
/apps/system/vi/vi.c:1128: undefined reference to `fopen'
/apps/system/vi/vi.c:1144: undefined reference to `fread'
/apps/system/vi/vi.c:1155: undefined reference to `fclose'
/os/../build/output/libraries/libapps.a(vi.o): In function `vi_main':
/apps/system/vi/vi.c:3385: undefined reference to `fprintf'
...
/os/../build/output/libraries/libapps.a(vi.o): In function `vi_main':
/apps/system/vi/vi.c:3356: undefined reference to `fprintf'
Shell use file operation APIs like open, fopen and so on.
This commit fixs below:
/os/../build/output/libraries/libapps.a(tash_script.o): In function `tash_script':
/apps/shell/tash_script.c:55: undefined reference to `fopen'
/apps/shell/tash_script.c:62: undefined reference to `fgets'
/apps/shell/tash_script.c:78: undefined reference to `fclose'
/os/../build/output/libraries/libapps.a(tash_main.o): In function `tash_open_console':
/apps/shell/tash_main.c:161: undefined reference to `open'
FS_CMDS use file operation APIs so that let's make a dependancy.
This commit fixs below:
/os/../build/output/libraries/libapps.a(fscmd.o): In function `tash_rmdir':
/apps/system/utils/fscmd.c:1058: undefined reference to `rmdir'
/os/../build/output/libraries/libapps.a(fscmd.o): In function `tash_rm':
/apps/system/utils/fscmd.c:1031: undefined reference to `unlink'
/os/../build/output/libraries/libapps.a(fscmd.o): In function `tash_umount':
/apps/system/utils/fscmd.c:985: undefined reference to `umount'
/os/../build/output/libraries/libapps.a(fscmd.o): In function `tash_mksmartfs':
/apps/system/utils/fscmd.c:827: undefined reference to `mksmartfs'
...
Script functionality on TASH is rarely used so that supporting disable script
functionality is better on footprint.
@seinfra
Copy link

seinfra commented Feb 26, 2018

Code Rule Check OK.

Poweroff application can be enabled when board supports poweroff functionality.
This commit fixs below:
/os/../build/output/libraries/libapps.a(poweroff.o): In function `poweroff_main':
/apps/system/poweroff/poweroff.c:68: undefined reference to `board_power_off'
@seinfra
Copy link

seinfra commented Feb 27, 2018

Code Rule Check OK.

@Taejun-Kwon Taejun-Kwon merged commit ebc5adc into Samsung:master Feb 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants