From a66fed62cce413cc7af40e8009b8bebd1904dbb8 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Tue, 25 Jun 2019 08:29:37 +0200 Subject: [PATCH] Format **/*.c with clang-format (!465) [ci:skip-build]: already built successfully in CI [ci:skip-vercheck] --- cross/crossdirect/APKBUILD | 2 +- cross/crossdirect/crossdirect.c | 41 +- main/fbdebug/APKBUILD | 2 +- main/fbdebug/fbdebug.c | 455 +++++++++--------- main/hello-world/APKBUILD | 2 +- main/hello-world/main.c | 4 +- .../APKBUILD | 2 +- .../disable-warning.c | 126 ++--- main/postmarketos-demos/APKBUILD | 2 +- main/postmarketos-demos/main.c | 37 +- main/reboot-mode/APKBUILD | 2 +- main/reboot-mode/reboot-mode.c | 17 +- 12 files changed, 341 insertions(+), 351 deletions(-) diff --git a/cross/crossdirect/APKBUILD b/cross/crossdirect/APKBUILD index a0bec9364..400b31da0 100644 --- a/cross/crossdirect/APKBUILD +++ b/cross/crossdirect/APKBUILD @@ -63,4 +63,4 @@ package() { done done } -sha512sums="f8366add6ba2ac6d9f8af89f389c69914009b12b21e6608121a78d1cd9afe287e24eafb0c21d80d096df9eee9a23cc2e6a5408f6355e27be05203186a0bf9814 crossdirect.c" +sha512sums="20b963322820de038257304c1eefa85767b78e242eda7459f06d70a1cfae5540a445aa7d5587024bf4d88a4bee28120ef9f5c2d24a648e71b542b9618318deb2 crossdirect.c" diff --git a/cross/crossdirect/crossdirect.c b/cross/crossdirect/crossdirect.c index 4a7d4cd49..46672b4bb 100644 --- a/cross/crossdirect/crossdirect.c +++ b/cross/crossdirect/crossdirect.c @@ -1,27 +1,29 @@ // HOSTSPEC is defined at compile time, see APKBUILD -#include -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include #include #define NATIVE_BIN_DIR "/native/usr/lib/ccache/bin" -void exit_userfriendly() { +void exit_userfriendly() +{ fprintf(stderr, "Please report this at: https://gitlab.com/postmarketOS/pmaports/issues\n"); fprintf(stderr, "As a workaround, you can compile without crossdirect.\n"); fprintf(stderr, "See 'pmbootstrap -h' for related options.\n"); exit(1); } -bool argv_has_arg(int argc, char** argv, const char* arg) { +bool argv_has_arg(int argc, char **argv, const char *arg) +{ size_t arg_len = strlen(arg); - for (int i=1; i < argc; i++) { + for (int i = 1; i < argc; i++) { if (strlen(argv[i]) < arg_len) continue; @@ -31,13 +33,14 @@ bool argv_has_arg(int argc, char** argv, const char* arg) { return false; } -int main(int argc, char** argv) { +int main(int argc, char **argv) +{ // we have a max of four extra args ("-target", "HOSTSPEC", "--sysroot=/", "-Wl,-rpath-link=/lib:/usr/lib"), plus one ending null - char* newargv[argc + 5]; - char* executableName = basename(argv[0]); + char *newargv[argc + 5]; + char *executableName = basename(argv[0]); char newExecutable[PATH_MAX]; bool isClang = (strcmp(executableName, "clang") == 0 || strcmp(executableName, "clang++") == 0); - bool startsWithHostSpec = (strncmp(HOSTSPEC, executableName, sizeof(HOSTSPEC) -1) == 0); + bool startsWithHostSpec = (strncmp(HOSTSPEC, executableName, sizeof(HOSTSPEC) - 1) == 0); // linker is involved: just use qemu binary (to avoid broken cross-ld, pmaports#227) if (!argv_has_arg(argc, argv, "-c")) { @@ -50,12 +53,12 @@ int main(int argc, char** argv) { } if (isClang || startsWithHostSpec) { - snprintf(newExecutable, sizeof(newExecutable), NATIVE_BIN_DIR "/%s", executableName); + snprintf(newExecutable, sizeof(newExecutable), NATIVE_BIN_DIR "/%s", executableName); } else { - snprintf(newExecutable, sizeof(newExecutable), NATIVE_BIN_DIR "/" HOSTSPEC "-%s", executableName); + snprintf(newExecutable, sizeof(newExecutable), NATIVE_BIN_DIR "/" HOSTSPEC "-%s", executableName); } - char** newArgsPtr = newargv; + char **newArgsPtr = newargv; *newArgsPtr++ = newExecutable; if (isClang) { *newArgsPtr++ = "-target"; @@ -63,16 +66,16 @@ int main(int argc, char** argv) { } *newArgsPtr++ = "--sysroot=/"; - memcpy(newArgsPtr, argv + 1, sizeof(char*)*(argc - 1)); + memcpy(newArgsPtr, argv + 1, sizeof(char *) * (argc - 1)); newArgsPtr += (argc - 1); *newArgsPtr = NULL; // new arguments prepared; now setup environmental vars - char* env[] = {"LD_PRELOAD=", + char *env[] = { "LD_PRELOAD=", "LD_LIBRARY_PATH=/native/lib:/native/usr/lib", "CCACHE_PATH=/native/usr/bin", - NULL}; - char* ldPreload = getenv("LD_PRELOAD"); + NULL }; + char *ldPreload = getenv("LD_PRELOAD"); if (ldPreload) { if (strcmp(ldPreload, "/usr/lib/libfakeroot.so") == 0) { env[0] = "LD_PRELOAD=/native/usr/lib/libfakeroot.so"; diff --git a/main/fbdebug/APKBUILD b/main/fbdebug/APKBUILD index 9c4a7c576..631d9cd16 100644 --- a/main/fbdebug/APKBUILD +++ b/main/fbdebug/APKBUILD @@ -22,4 +22,4 @@ package() { "${pkgdir}/usr/sbin/fbdebug" } -sha512sums="c75972faa180567fccabf63723693a3dfe6240f891eee9d580a1bfce2a8858cb746a4cc9704990f90abe94f3759ac47ca5203f1309e525d880a8663235a7e209 fbdebug.c" +sha512sums="c2b99024d4d3f1a47b5dcdff175b611d3c16175553076badafdaf9628ed85f95d955d09366a25d34a0f63a00c58bbdd063f6f531f60254b20420d47d7e3adb2f fbdebug.c" diff --git a/main/fbdebug/fbdebug.c b/main/fbdebug/fbdebug.c index 039217b43..a78bf6301 100644 --- a/main/fbdebug/fbdebug.c +++ b/main/fbdebug/fbdebug.c @@ -15,19 +15,19 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include -#include -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include #include +#include -void usage(char* appname) +void usage(char *appname) { - printf("Usage: %s [-d DEV] [-i] [-c length] [-p] [-m mode] [-h]\n\ + printf("Usage: %s [-d DEV] [-i] [-c length] [-p] [-m mode] [-h]\n\ -d Framebuffer device (default /dev/fb0)\n\ -i Show fixed and variable screen info\n\ -c Show colormap values (length 0-256)\n\ @@ -36,253 +36,244 @@ void usage(char* appname) 2 => Standby\n\ 3 => Suspend\n\ 4 => Off\n\ - -h Show this help\n", appname); + -h Show this help\n", + appname); } -void print_fix_screeninfo(struct fb_fix_screeninfo* scr_fix) +void print_fix_screeninfo(struct fb_fix_screeninfo *scr_fix) { - // ref: https://elixir.bootlin.com/linux/latest/ident/fb_fix_screeninfo - printf("Fixed screen info:\n"); - printf("\tid = %s\n", scr_fix->id); - printf("\tsmem_start = %lu\n", scr_fix->smem_start); - printf("\tsmem_len = %u\n", scr_fix->smem_len); - printf("\ttype = %u\n", scr_fix->type); - printf("\ttype_aux = %u\n", scr_fix->type_aux); - printf("\tvisual = %u\n", scr_fix->visual); - printf("\txpanstep = %hu\n", scr_fix->xpanstep); - printf("\typanstep = %hu\n", scr_fix->ypanstep); - printf("\tywrapstep = %hu\n", scr_fix->ywrapstep); - printf("\tline_length = %u\n", scr_fix->line_length); - printf("\tmmio_start = %lu\n", scr_fix->mmio_start); - printf("\tmmio_len = %u\n", scr_fix->mmio_len); - printf("\taccel = %u\n", scr_fix->accel); - printf("\tcapabilities = %hu\n", scr_fix->capabilities); - printf("\treserved[0] = %hu\n", scr_fix->reserved[0]); - printf("\treserved[1] = %hu\n", scr_fix->reserved[1]); + // ref: https://elixir.bootlin.com/linux/latest/ident/fb_fix_screeninfo + printf("Fixed screen info:\n"); + printf("\tid = %s\n", scr_fix->id); + printf("\tsmem_start = %lu\n", scr_fix->smem_start); + printf("\tsmem_len = %u\n", scr_fix->smem_len); + printf("\ttype = %u\n", scr_fix->type); + printf("\ttype_aux = %u\n", scr_fix->type_aux); + printf("\tvisual = %u\n", scr_fix->visual); + printf("\txpanstep = %hu\n", scr_fix->xpanstep); + printf("\typanstep = %hu\n", scr_fix->ypanstep); + printf("\tywrapstep = %hu\n", scr_fix->ywrapstep); + printf("\tline_length = %u\n", scr_fix->line_length); + printf("\tmmio_start = %lu\n", scr_fix->mmio_start); + printf("\tmmio_len = %u\n", scr_fix->mmio_len); + printf("\taccel = %u\n", scr_fix->accel); + printf("\tcapabilities = %hu\n", scr_fix->capabilities); + printf("\treserved[0] = %hu\n", scr_fix->reserved[0]); + printf("\treserved[1] = %hu\n", scr_fix->reserved[1]); } -void print_var_screeninfo(struct fb_var_screeninfo* scr_var) +void print_var_screeninfo(struct fb_var_screeninfo *scr_var) { - // ref: https://elixir.bootlin.com/linux/latest/ident/fb_var_screeninfo - printf("Variable screen info:\n"); - printf("\txres = %u\n", scr_var->xres); - printf("\tyres = %u\n", scr_var->yres); - printf("\txres_virtual = %u\n", scr_var->xres_virtual); - printf("\tyres_virtual = %u\n", scr_var->yres_virtual); - printf("\txoffset = %u\n", scr_var->xoffset); - printf("\tyoffset = %u\n", scr_var->yoffset); - printf("\tbits_per_pixel = %u\n", scr_var->bits_per_pixel); - printf("\tgrayscale = %u\n", scr_var->grayscale); - printf("\tred.offset = %u\n", scr_var->red.offset); - printf("\tred.length = %u\n", scr_var->red.length); - printf("\tred.msb_right = %u\n", scr_var->red.msb_right); - printf("\tgreen.offset = %u\n", scr_var->green.offset); - printf("\tgreen.length = %u\n", scr_var->green.length); - printf("\tgreen.msb_right = %u\n", scr_var->green.msb_right); - printf("\tblue.offset = %u\n", scr_var->blue.offset); - printf("\tblue.length = %u\n", scr_var->blue.length); - printf("\tblue.msb_right = %u\n", scr_var->blue.msb_right); - printf("\ttransp.offset = %u\n", scr_var->transp.offset); - printf("\ttransp.length = %u\n", scr_var->transp.length); - printf("\ttransp.msb_right = %u\n", scr_var->transp.msb_right); - printf("\tnonstd = %u\n", scr_var->nonstd); - printf("\tactivate = %u\n", scr_var->activate); - printf("\theight = %u\n", scr_var->height); - printf("\twidth = %u\n", scr_var->width); - printf("\taccel_flags = %u\n", scr_var->accel_flags); - printf("\tpixclock = %u\n", scr_var->pixclock); - printf("\tleft_margin = %u\n", scr_var->left_margin); - printf("\tright_margin = %u\n", scr_var->right_margin); - printf("\tupper_margin = %u\n", scr_var->upper_margin); - printf("\tlower_margin = %u\n", scr_var->lower_margin); - printf("\thsync_len = %u\n", scr_var->hsync_len); - printf("\tvsync_len = %u\n", scr_var->vsync_len); - printf("\tsync = %u\n", scr_var->sync); - printf("\tvmode = %u\n", scr_var->vmode); - printf("\trotate = %u\n", scr_var->rotate); - printf("\tcolorspace = %u\n", scr_var->colorspace); - printf("\treserved[0] = %u\n", scr_var->reserved[0]); - printf("\treserved[1] = %u\n", scr_var->reserved[1]); - printf("\treserved[2] = %u\n", scr_var->reserved[2]); - printf("\treserved[3] = %u\n", scr_var->reserved[3]); + // ref: https://elixir.bootlin.com/linux/latest/ident/fb_var_screeninfo + printf("Variable screen info:\n"); + printf("\txres = %u\n", scr_var->xres); + printf("\tyres = %u\n", scr_var->yres); + printf("\txres_virtual = %u\n", scr_var->xres_virtual); + printf("\tyres_virtual = %u\n", scr_var->yres_virtual); + printf("\txoffset = %u\n", scr_var->xoffset); + printf("\tyoffset = %u\n", scr_var->yoffset); + printf("\tbits_per_pixel = %u\n", scr_var->bits_per_pixel); + printf("\tgrayscale = %u\n", scr_var->grayscale); + printf("\tred.offset = %u\n", scr_var->red.offset); + printf("\tred.length = %u\n", scr_var->red.length); + printf("\tred.msb_right = %u\n", scr_var->red.msb_right); + printf("\tgreen.offset = %u\n", scr_var->green.offset); + printf("\tgreen.length = %u\n", scr_var->green.length); + printf("\tgreen.msb_right = %u\n", scr_var->green.msb_right); + printf("\tblue.offset = %u\n", scr_var->blue.offset); + printf("\tblue.length = %u\n", scr_var->blue.length); + printf("\tblue.msb_right = %u\n", scr_var->blue.msb_right); + printf("\ttransp.offset = %u\n", scr_var->transp.offset); + printf("\ttransp.length = %u\n", scr_var->transp.length); + printf("\ttransp.msb_right = %u\n", scr_var->transp.msb_right); + printf("\tnonstd = %u\n", scr_var->nonstd); + printf("\tactivate = %u\n", scr_var->activate); + printf("\theight = %u\n", scr_var->height); + printf("\twidth = %u\n", scr_var->width); + printf("\taccel_flags = %u\n", scr_var->accel_flags); + printf("\tpixclock = %u\n", scr_var->pixclock); + printf("\tleft_margin = %u\n", scr_var->left_margin); + printf("\tright_margin = %u\n", scr_var->right_margin); + printf("\tupper_margin = %u\n", scr_var->upper_margin); + printf("\tlower_margin = %u\n", scr_var->lower_margin); + printf("\thsync_len = %u\n", scr_var->hsync_len); + printf("\tvsync_len = %u\n", scr_var->vsync_len); + printf("\tsync = %u\n", scr_var->sync); + printf("\tvmode = %u\n", scr_var->vmode); + printf("\trotate = %u\n", scr_var->rotate); + printf("\tcolorspace = %u\n", scr_var->colorspace); + printf("\treserved[0] = %u\n", scr_var->reserved[0]); + printf("\treserved[1] = %u\n", scr_var->reserved[1]); + printf("\treserved[2] = %u\n", scr_var->reserved[2]); + printf("\treserved[3] = %u\n", scr_var->reserved[3]); } -void print_cmap(struct fb_cmap* scr_cmap) +void print_cmap(struct fb_cmap *scr_cmap) { - // ref: https://elixir.bootlin.com/linux/latest/ident/fb_cmap - printf("Colormap:\n"); - printf("\tstart = %u\n", scr_cmap->start); - printf("\tlen = %u\n", scr_cmap->len); - printf("\tred = "); - for (int i = 0; i < scr_cmap->len; i++) { - if (i > 0 && i % 8 == 0) { - printf("\n\t\t "); - } - printf("0x%04hX ", scr_cmap->red[i]); - } - printf("\n"); - printf("\tgreen = "); - for (int i = 0; i < scr_cmap->len; i++) { - if (i > 0 && i % 8 == 0) { - printf("\n\t\t "); - } - printf("0x%04hX ", scr_cmap->green[i]); - } - printf("\n"); - printf("\tblue = "); - for (int i = 0; i < scr_cmap->len; i++) { - if (i > 0 && i % 8 == 0) { - printf("\n\t\t "); - } - printf("0x%04hX ", scr_cmap->blue[i]); - } - printf("\n"); - printf("\ttransp = "); - for (int i = 0; i < scr_cmap->len; i++) { - if (i > 0 && i % 8 == 0) { - printf("\n\t\t "); - } - printf("0x%04hX ", scr_cmap->transp[i]); - } - printf("\n"); + // ref: https://elixir.bootlin.com/linux/latest/ident/fb_cmap + printf("Colormap:\n"); + printf("\tstart = %u\n", scr_cmap->start); + printf("\tlen = %u\n", scr_cmap->len); + printf("\tred = "); + for (int i = 0; i < scr_cmap->len; i++) { + if (i > 0 && i % 8 == 0) { + printf("\n\t\t "); + } + printf("0x%04hX ", scr_cmap->red[i]); + } + printf("\n"); + printf("\tgreen = "); + for (int i = 0; i < scr_cmap->len; i++) { + if (i > 0 && i % 8 == 0) { + printf("\n\t\t "); + } + printf("0x%04hX ", scr_cmap->green[i]); + } + printf("\n"); + printf("\tblue = "); + for (int i = 0; i < scr_cmap->len; i++) { + if (i > 0 && i % 8 == 0) { + printf("\n\t\t "); + } + printf("0x%04hX ", scr_cmap->blue[i]); + } + printf("\n"); + printf("\ttransp = "); + for (int i = 0; i < scr_cmap->len; i++) { + if (i > 0 && i % 8 == 0) { + printf("\n\t\t "); + } + printf("0x%04hX ", scr_cmap->transp[i]); + } + printf("\n"); } -int main(int argc, char** argv) +int main(int argc, char **argv) { - const char *fb_device; - struct fb_fix_screeninfo scr_fix; - struct fb_var_screeninfo scr_var; - struct fb_cmap scr_cmap; - int fb_fd; + const char *fb_device; + struct fb_fix_screeninfo scr_fix; + struct fb_var_screeninfo scr_var; + struct fb_cmap scr_cmap; + int fb_fd; - // parse command line options - fb_device = "/dev/fb0"; - bool show_info = false; - bool show_cmap = false; - int cmap_len; - bool pan_display = false; - bool set_fbmode = false; - int fbmode; + // parse command line options + fb_device = "/dev/fb0"; + bool show_info = false; + bool show_cmap = false; + int cmap_len; + bool pan_display = false; + bool set_fbmode = false; + int fbmode; - if (argc < 2) - { - usage(argv[0]); - exit(1); - } - int opt; - while ((opt = getopt(argc, argv, "d:ic:pm:h")) != -1) - { - switch (opt) - { - case 'd': - fb_device = optarg; - break; - case 'i': - show_info = true; - break; - case 'c': - show_cmap = true; - cmap_len = atoi(optarg); - break; - case 'p': - pan_display = true; - break; - case 'm': - set_fbmode = true; - fbmode = atoi(optarg); - break; - case 'h': - default: - usage(argv[0]); - exit(1); - } - } + if (argc < 2) { + usage(argv[0]); + exit(1); + } + int opt; + while ((opt = getopt(argc, argv, "d:ic:pm:h")) != -1) { + switch (opt) { + case 'd': + fb_device = optarg; + break; + case 'i': + show_info = true; + break; + case 'c': + show_cmap = true; + cmap_len = atoi(optarg); + break; + case 'p': + pan_display = true; + break; + case 'm': + set_fbmode = true; + fbmode = atoi(optarg); + break; + case 'h': + default: + usage(argv[0]); + exit(1); + } + } - // open the framebuffer device - fb_fd = open(fb_device, O_RDWR); - if (fb_fd < 0) - { - printf("Unable to open %s.\n", fb_device); - return 1; - } + // open the framebuffer device + fb_fd = open(fb_device, O_RDWR); + if (fb_fd < 0) { + printf("Unable to open %s.\n", fb_device); + return 1; + } - // call ioctl. retrieve fixed screen info - if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &scr_fix) < 0) - { - printf("Unable to retrieve fixed screen info: %s\n", - strerror(errno)); - close(fb_fd); - return 1; - } + // call ioctl. retrieve fixed screen info + if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &scr_fix) < 0) { + printf("Unable to retrieve fixed screen info: %s\n", + strerror(errno)); + close(fb_fd); + return 1; + } - // print all the fixed screen info values - if (show_info) - print_fix_screeninfo(&scr_fix); + // print all the fixed screen info values + if (show_info) + print_fix_screeninfo(&scr_fix); - // call ioctl. retrieve variable screen info - if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &scr_var) < 0) - { - printf("Unable to retrieve variable screen info: %s\n", - strerror(errno)); - close(fb_fd); - return 1; - } + // call ioctl. retrieve variable screen info + if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &scr_var) < 0) { + printf("Unable to retrieve variable screen info: %s\n", + strerror(errno)); + close(fb_fd); + return 1; + } - // print all the variable screen info values - if (show_info) - print_var_screeninfo(&scr_var); + // print all the variable screen info values + if (show_info) + print_var_screeninfo(&scr_var); - // call ioctl. retrieve colormap - if (show_cmap) { - scr_cmap.start = 0; - scr_cmap.len = cmap_len; - scr_cmap.red = calloc(256, sizeof(unsigned short)); - scr_cmap.green = calloc(256, sizeof(unsigned short)); - scr_cmap.blue = calloc(256, sizeof(unsigned short)); - scr_cmap.transp = calloc(256, sizeof(unsigned short)); - if (ioctl(fb_fd, FBIOGETCMAP, &scr_cmap) < 0) - { - printf("Unable to retrieve cmap info: %s\n", - strerror(errno)); - free(scr_cmap.red); - free(scr_cmap.green); - free(scr_cmap.blue); - free(scr_cmap.transp); - close(fb_fd); - return 1; - } + // call ioctl. retrieve colormap + if (show_cmap) { + scr_cmap.start = 0; + scr_cmap.len = cmap_len; + scr_cmap.red = calloc(256, sizeof(unsigned short)); + scr_cmap.green = calloc(256, sizeof(unsigned short)); + scr_cmap.blue = calloc(256, sizeof(unsigned short)); + scr_cmap.transp = calloc(256, sizeof(unsigned short)); + if (ioctl(fb_fd, FBIOGETCMAP, &scr_cmap) < 0) { + printf("Unable to retrieve cmap info: %s\n", + strerror(errno)); + free(scr_cmap.red); + free(scr_cmap.green); + free(scr_cmap.blue); + free(scr_cmap.transp); + close(fb_fd); + return 1; + } - // print all the cmap values - print_cmap(&scr_cmap); + // print all the cmap values + print_cmap(&scr_cmap); - free(scr_cmap.red); - free(scr_cmap.green); - free(scr_cmap.blue); - free(scr_cmap.transp); - } + free(scr_cmap.red); + free(scr_cmap.green); + free(scr_cmap.blue); + free(scr_cmap.transp); + } - if (pan_display) - { - // call ioctl. pan the display - if (ioctl(fb_fd, FBIOPAN_DISPLAY, &scr_var) < 0) - { - printf("Unable to pan the display: %s\n", - strerror(errno)); - close(fb_fd); - return 1; - } - } + if (pan_display) { + // call ioctl. pan the display + if (ioctl(fb_fd, FBIOPAN_DISPLAY, &scr_var) < 0) { + printf("Unable to pan the display: %s\n", + strerror(errno)); + close(fb_fd); + return 1; + } + } - if (set_fbmode) { - if (ioctl(fb_fd, FBIOBLANK, (void *)fbmode) < 0) - { - printf("Unable to set fb mode: %s\n", - strerror(errno)); - close(fb_fd); - return 1; - } - } + if (set_fbmode) { + if (ioctl(fb_fd, FBIOBLANK, (void *)fbmode) < 0) { + printf("Unable to set fb mode: %s\n", + strerror(errno)); + close(fb_fd); + return 1; + } + } - // close the framebuffer device - close(fb_fd); + // close the framebuffer device + close(fb_fd); } diff --git a/main/hello-world/APKBUILD b/main/hello-world/APKBUILD index 37ee6ca17..93c6db633 100644 --- a/main/hello-world/APKBUILD +++ b/main/hello-world/APKBUILD @@ -27,5 +27,5 @@ package() { install -D -m755 "$srcdir"/hello-world \ "$pkgdir"/usr/bin/hello-world } -sha512sums="d5ad91600d9be3e53be4cb6e5846b0757786c947b2c0d10f612f67262fc91c148e8d73621623e259ca9dcd5e2c8ec7069cebec44165e203ea8c0133669d3382d main.c +sha512sums="62385af6a68cd4e0c03b15992bb9f1d20b8d6c8a33724ca2d28629a139e95016d0502257f8a3a8be53eef30e11b3e372a2469cb1989dbd387ebea4464a9273ee main.c 80c32948d3254f5e4f9084d73754824e7d7d7d117770b041a1a13baf056773de265153fe518cc3e735db55b638411aa6fbd0e17b5b674dfc89e69a9391fbd3bb Makefile" diff --git a/main/hello-world/main.c b/main/hello-world/main.c index 76bb8fad2..8ac5cc3ee 100644 --- a/main/hello-world/main.c +++ b/main/hello-world/main.c @@ -2,6 +2,6 @@ int main() { - printf("hello, world!\n"); - return 0; + printf("hello, world!\n"); + return 0; } diff --git a/main/postmarketos-android-recovery-installer/APKBUILD b/main/postmarketos-android-recovery-installer/APKBUILD index 321a366fb..fb3333cd1 100644 --- a/main/postmarketos-android-recovery-installer/APKBUILD +++ b/main/postmarketos-android-recovery-installer/APKBUILD @@ -36,7 +36,7 @@ package() { } sha512sums="cd3c4a4bb246d8e2480a9968d3519373ab55126a5b77e975ce53333ed39349194f1afb0dea472d62bdb0ffef1ac93bbadaf3de6362db47ef34c922a1e65c95db build_zip.sh bb152e86ce420761dd2dca660552131610bb8f39cb7e30c75689aacc7cccddce17a90c998097f1b63b3d68a20f9c2c4823d8d591de156dff827381fe436f3b9d update-binary -38c21dc80aa2530fc06c2960c1318e07d068d403af02133f09ba227106a9b23fb77c3bed904e6135b048846f2733bd5d043235e5ab04598ed9c8fa45cbb15586 disable-warning.c +3e6388602665367990bdf4c068268160c26a80dda7fa43380755f36f1ca8751f4ec8a584a4cce3b37f41d405a992716c4280077d062e186b4027d6b74db84b3c disable-warning.c 2400d18734d08b3d2f5ec2fe4e802cdcacddea851644b47505eff1aac47302699c171b880bca55dd1704cc9cef9ac26082ac89cee802b6bf57ff8cf649373328 pmos_chroot ef6377f6c062b9a86eb9dfb2aa2c0049fda20f24ec75865a682a50e4655710a18bd7a470deab527e1dd4c273f9ea6a003ec03fc5748d44b1c4fbfc91baa9e358 pmos_install 1b19d507a9142e537d052037a0c0768f064ad9131ac8019b234178dc15c0590dbc549ccf553b7a7d55e977df269d4dc0567b520c890738cb80184fc8235222aa pmos_install_functions diff --git a/main/postmarketos-android-recovery-installer/disable-warning.c b/main/postmarketos-android-recovery-installer/disable-warning.c index 65cb9e3c3..f3dc40013 100644 --- a/main/postmarketos-android-recovery-installer/disable-warning.c +++ b/main/postmarketos-android-recovery-installer/disable-warning.c @@ -17,61 +17,61 @@ * along with postmarketos-android-recovery-installer. If not, see . */ +#include +#include #include #include -#include -#include -#include #include -#include -#include +#include +#include +#include void close_FDs() { - unsigned int fd; - struct dirent* ep; - DIR* dp = opendir("/proc/self/fd"); - if (dp != NULL) { - // first two entries are . and .. - readdir(dp); - readdir(dp); + unsigned int fd; + struct dirent *ep; + DIR *dp = opendir("/proc/self/fd"); + if (dp != NULL) { + // first two entries are . and .. + readdir(dp); + readdir(dp); - while (ep = readdir(dp)) - if (sscanf(ep->d_name, "%u", &fd) != EOF) - close(fd); - closedir(dp); - } else { - // try to close all file descriptors by brute-force - // in case the list of open FDs could not be read - // from the procfs - for (fd = 256; fd >= 0; fd--) - close(fd); - } + while (ep = readdir(dp)) + if (sscanf(ep->d_name, "%u", &fd) != EOF) + close(fd); + closedir(dp); + } else { + // try to close all file descriptors by brute-force + // in case the list of open FDs could not be read + // from the procfs + for (fd = 256; fd >= 0; fd--) + close(fd); + } } // Detach the program from the installation script void daemonize() { - pid_t pid; + pid_t pid; - pid = fork(); - if (pid < 0) - exit(1); - if (pid > 0) - exit(0); + pid = fork(); + if (pid < 0) + exit(1); + if (pid > 0) + exit(0); - if (setsid() < 0) - exit(1); + if (setsid() < 0) + exit(1); - pid = fork(); - if (pid < 0) - exit(1); - if (pid > 0) - exit(0); + pid = fork(); + if (pid < 0) + exit(1); + if (pid > 0) + exit(0); - umask(0); - chdir("/"); - close_FDs(); + umask(0); + chdir("/"); + close_FDs(); } // Workaround to disable No OS warning in TWRP @@ -88,36 +88,36 @@ void daemonize() // exited. int main() { - daemonize(); + daemonize(); - int orsin, orsout; + int orsin, orsout; - char command[1024]; - char result[512]; + char command[1024]; + char result[512]; - char* commands[] = {"set tw_backup_system_size 999", - "set tw_app_prompt 0"}; + char *commands[] = { "set tw_backup_system_size 999", + "set tw_app_prompt 0" }; - sleep(4); + sleep(4); - int i; - for (i = 0; i < sizeof(commands)/sizeof(char*); i++) { - if ((orsin = open("/sbin/orsin", O_WRONLY)) == -1) - return 1; - strcpy(command, commands[i]); - write(orsin, command, sizeof(command)); - close(orsin); + int i; + for (i = 0; i < sizeof(commands) / sizeof(char *); i++) { + if ((orsin = open("/sbin/orsin", O_WRONLY)) == -1) + return 1; + strcpy(command, commands[i]); + write(orsin, command, sizeof(command)); + close(orsin); - // Have to read FIFO file, because it blocks - // the thread processing the command - // (see man 3 mkfifo) - if ((orsout = open("/sbin/orsout", O_RDONLY)) == -1) - return 1; - read(orsout, result, sizeof(result)); - close(orsout); + // Have to read FIFO file, because it blocks + // the thread processing the command + // (see man 3 mkfifo) + if ((orsout = open("/sbin/orsout", O_RDONLY)) == -1) + return 1; + read(orsout, result, sizeof(result)); + close(orsout); - sleep(3); - } + sleep(3); + } - return 0; + return 0; } diff --git a/main/postmarketos-demos/APKBUILD b/main/postmarketos-demos/APKBUILD index b5615e1a7..4e1ae8457 100644 --- a/main/postmarketos-demos/APKBUILD +++ b/main/postmarketos-demos/APKBUILD @@ -20,5 +20,5 @@ package() { install -D -m755 "$srcdir"/postmarketos-demos \ "$pkgdir"/usr/bin/postmarketos-demos } -sha512sums="48db2907ea609bcdafd321aa8659a387ad6325641e01fd83d91be5d320eb6202ab628b73d914658333396e7751e1e283aed413db7e91cce2d782993ef38a7e05 main.c +sha512sums="804bbd4e939bd49a153919a728ee17cf69e98e5d679f106054edf298d775849f8efa4716814ee4b84eaa6bcc2c38d16c2362922978cdd214290dd4968ce645bc main.c 83d8a95e9e1e95dffa8661e547444e83e72e572dcd0c637376f678bbd20a351c4b971a315311edefeb58a4cca14fd3e586fb581a262b2d217e25092459539b98 Makefile" diff --git a/main/postmarketos-demos/main.c b/main/postmarketos-demos/main.c index 05dc082fa..a875bad85 100644 --- a/main/postmarketos-demos/main.c +++ b/main/postmarketos-demos/main.c @@ -3,56 +3,55 @@ static void onclick(GtkWidget *widget, gpointer command) { - system((const char*)command); + system((const char *)command); } static void activate(GtkApplication *app, gpointer user_data) { GtkWidget *window = gtk_application_window_new(app); - gtk_window_set_title(GTK_WINDOW (window), "postmarketOS demos"); + gtk_window_set_title(GTK_WINDOW(window), "postmarketOS demos"); GtkWidget *button_box = gtk_button_box_new( GTK_ORIENTATION_VERTICAL); - gtk_container_add(GTK_CONTAINER (window), button_box); + gtk_container_add(GTK_CONTAINER(window), button_box); const char *programs[] = { "GTK3 Demo", - "gtk3-demo &", + "gtk3-demo &", "Firefox (XWayland, needs to be installed)", - "firefox &", + "firefox &", "weston-presentation-shm (Animation)", - "weston-presentation-shm &", + "weston-presentation-shm &", "weston-simple-damage (Animation)", - "weston-simple-damage &", + "weston-simple-damage &", "weston-smoke (Touch)", - "weston-smoke &", + "weston-smoke &", "weston-editor (Touch)", - "weston-editor &", + "weston-editor &", "htop (Terminal)", - "weston-terminal -f --shell=/usr/bin/htop &", + "weston-terminal -f --shell=/usr/bin/htop &", "Restart Weston", - "killall weston &", + "killall weston &", }; - for(int i=0;i<(sizeof(programs) / sizeof(const char*));i+=2) - { + for (int i = 0; i < (sizeof(programs) / sizeof(const char *)); i += 2) { const char *title = programs[i]; - const char *command = programs[i+1]; + const char *command = programs[i + 1]; GtkWidget *button = gtk_button_new_with_label(title); gtk_widget_set_size_request(button, 200, 70); - g_signal_connect(button, "clicked", G_CALLBACK (onclick), - (void*)command); + g_signal_connect(button, "clicked", G_CALLBACK(onclick), + (void *)command); gtk_container_add(GTK_CONTAINER(button_box), button); } - gtk_widget_show_all (window); + gtk_widget_show_all(window); } -int main (int argc, char **argv) +int main(int argc, char **argv) { GtkApplication *app = gtk_application_new("org.postmarketos.demos", G_APPLICATION_FLAGS_NONE); - g_signal_connect (app, "activate", G_CALLBACK(activate), NULL); + g_signal_connect(app, "activate", G_CALLBACK(activate), NULL); int status = g_application_run(G_APPLICATION(app), argc, argv); g_object_unref(app); return status; diff --git a/main/reboot-mode/APKBUILD b/main/reboot-mode/APKBUILD index dc52a3a5b..2b805cb8a 100644 --- a/main/reboot-mode/APKBUILD +++ b/main/reboot-mode/APKBUILD @@ -22,4 +22,4 @@ package() { "${pkgdir}/usr/sbin/reboot-mode" } -sha512sums="569b6b1cf595e208b8c5731ea8d4334cd5458cbc2a63d5756014f55f04dd89a4b67ec0d0d01d7a1cd935ae13d44e62e3ea6765f626736bc3dc2029b890c20070 reboot-mode.c" +sha512sums="37d282608f30b1b8fa4f7501a8afcaa81902c9dfaee0c4c92ab05028e3a99a69c601dc7fce6ab06582db044b6fd0f5bffabe9d6064af9e670266978d66fe2515 reboot-mode.c" diff --git a/main/reboot-mode/reboot-mode.c b/main/reboot-mode/reboot-mode.c index d94dca474..36561d9b3 100644 --- a/main/reboot-mode/reboot-mode.c +++ b/main/reboot-mode/reboot-mode.c @@ -4,14 +4,14 @@ * * Copyright (C) 2019 Daniele Debernardi */ +#include #include #include #include -#include #include -#include +#include -void usage(char* appname) +void usage(char *appname) { printf("Usage: %s [-h] MODE\n\n", appname); printf("Reboot the device to the MODE specified (e.g. recovery, bootloader)\n\n"); @@ -20,19 +20,16 @@ void usage(char* appname) printf(" -h Show this help message and exit\n"); } -int main(int argc, char** argv) +int main(int argc, char **argv) { - if (argc != 2) - { + if (argc != 2) { usage(argv[0]); exit(1); } int opt; - while ((opt = getopt(argc, argv, "h")) != -1) - { - switch (opt) - { + while ((opt = getopt(argc, argv, "h")) != -1) { + switch (opt) { case 'h': default: usage(argv[0]);