Format **/*.c with clang-format (!465)

[ci:skip-build]: already built successfully in CI
[ci:skip-vercheck]
This commit is contained in:
Luca Weiss 2019-06-25 08:29:37 +02:00 committed by Oliver Smith
parent 90e2cc7eff
commit a66fed62cc
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
12 changed files with 341 additions and 351 deletions

View file

@ -63,4 +63,4 @@ package() {
done
done
}
sha512sums="f8366add6ba2ac6d9f8af89f389c69914009b12b21e6608121a78d1cd9afe287e24eafb0c21d80d096df9eee9a23cc2e6a5408f6355e27be05203186a0bf9814 crossdirect.c"
sha512sums="20b963322820de038257304c1eefa85767b78e242eda7459f06d70a1cfae5540a445aa7d5587024bf4d88a4bee28120ef9f5c2d24a648e71b542b9618318deb2 crossdirect.c"

View file

@ -1,27 +1,29 @@
// HOSTSPEC is defined at compile time, see APKBUILD
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <libgen.h>
#include <errno.h>
#include <libgen.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#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")) {
@ -55,7 +58,7 @@ int main(int argc, char** argv) {
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";

View file

@ -22,4 +22,4 @@ package() {
"${pkgdir}/usr/sbin/fbdebug"
}
sha512sums="c75972faa180567fccabf63723693a3dfe6240f891eee9d580a1bfce2a8858cb746a4cc9704990f90abe94f3759ac47ca5203f1309e525d880a8663235a7e209 fbdebug.c"
sha512sums="c2b99024d4d3f1a47b5dcdff175b611d3c16175553076badafdaf9628ed85f95d955d09366a25d34a0f63a00c58bbdd063f6f531f60254b20420d47d7e3adb2f fbdebug.c"

View file

@ -15,17 +15,17 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
void usage(char* appname)
void usage(char *appname)
{
printf("Usage: %s [-d DEV] [-i] [-c length] [-p] [-m mode] [-h]\n\
-d Framebuffer device (default /dev/fb0)\n\
@ -36,10 +36,11 @@ 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");
@ -61,7 +62,7 @@ void print_fix_screeninfo(struct fb_fix_screeninfo* scr_fix)
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");
@ -107,7 +108,7 @@ void print_var_screeninfo(struct fb_var_screeninfo* scr_var)
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");
@ -147,7 +148,7 @@ void print_cmap(struct fb_cmap* scr_cmap)
printf("\n");
}
int main(int argc, char** argv)
int main(int argc, char **argv)
{
const char *fb_device;
struct fb_fix_screeninfo scr_fix;
@ -164,16 +165,13 @@ int main(int argc, char** argv)
bool set_fbmode = false;
int fbmode;
if (argc < 2)
{
if (argc < 2) {
usage(argv[0]);
exit(1);
}
int opt;
while ((opt = getopt(argc, argv, "d:ic:pm:h")) != -1)
{
switch (opt)
{
while ((opt = getopt(argc, argv, "d:ic:pm:h")) != -1) {
switch (opt) {
case 'd':
fb_device = optarg;
break;
@ -200,15 +198,13 @@ int main(int argc, char** argv)
// open the framebuffer device
fb_fd = open(fb_device, O_RDWR);
if (fb_fd < 0)
{
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)
{
if (ioctl(fb_fd, FBIOGET_FSCREENINFO, &scr_fix) < 0) {
printf("Unable to retrieve fixed screen info: %s\n",
strerror(errno));
close(fb_fd);
@ -220,8 +216,7 @@ int main(int argc, char** argv)
print_fix_screeninfo(&scr_fix);
// call ioctl. retrieve variable screen info
if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &scr_var) < 0)
{
if (ioctl(fb_fd, FBIOGET_VSCREENINFO, &scr_var) < 0) {
printf("Unable to retrieve variable screen info: %s\n",
strerror(errno));
close(fb_fd);
@ -240,8 +235,7 @@ int main(int argc, char** argv)
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)
{
if (ioctl(fb_fd, FBIOGETCMAP, &scr_cmap) < 0) {
printf("Unable to retrieve cmap info: %s\n",
strerror(errno));
free(scr_cmap.red);
@ -261,11 +255,9 @@ int main(int argc, char** argv)
free(scr_cmap.transp);
}
if (pan_display)
{
if (pan_display) {
// call ioctl. pan the display
if (ioctl(fb_fd, FBIOPAN_DISPLAY, &scr_var) < 0)
{
if (ioctl(fb_fd, FBIOPAN_DISPLAY, &scr_var) < 0) {
printf("Unable to pan the display: %s\n",
strerror(errno));
close(fb_fd);
@ -274,8 +266,7 @@ int main(int argc, char** argv)
}
if (set_fbmode) {
if (ioctl(fb_fd, FBIOBLANK, (void *)fbmode) < 0)
{
if (ioctl(fb_fd, FBIOBLANK, (void *)fbmode) < 0) {
printf("Unable to set fb mode: %s\n",
strerror(errno));
close(fb_fd);

View file

@ -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"

View file

@ -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

View file

@ -17,20 +17,20 @@
* along with postmarketos-android-recovery-installer. If not, see <http:www.gnu.org/licenses/>.
*/
#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
void close_FDs()
{
unsigned int fd;
struct dirent* ep;
DIR* dp = opendir("/proc/self/fd");
struct dirent *ep;
DIR *dp = opendir("/proc/self/fd");
if (dp != NULL) {
// first two entries are . and ..
readdir(dp);
@ -95,13 +95,13 @@ int main()
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);
int i;
for (i = 0; i < sizeof(commands)/sizeof(char*); i++) {
for (i = 0; i < sizeof(commands) / sizeof(char *); i++) {
if ((orsin = open("/sbin/orsin", O_WRONLY)) == -1)
return 1;
strcpy(command, commands[i]);

View file

@ -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"

View file

@ -3,17 +3,17 @@
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",
@ -34,25 +34,24 @@ static void activate(GtkApplication *app, gpointer user_data)
"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;

View file

@ -22,4 +22,4 @@ package() {
"${pkgdir}/usr/sbin/reboot-mode"
}
sha512sums="569b6b1cf595e208b8c5731ea8d4334cd5458cbc2a63d5756014f55f04dd89a4b67ec0d0d01d7a1cd935ae13d44e62e3ea6765f626736bc3dc2029b890c20070 reboot-mode.c"
sha512sums="37d282608f30b1b8fa4f7501a8afcaa81902c9dfaee0c4c92ab05028e3a99a69c601dc7fce6ab06582db044b6fd0f5bffabe9d6064af9e670266978d66fe2515 reboot-mode.c"

View file

@ -4,14 +4,14 @@
*
* Copyright (C) 2019 Daniele Debernardi <drebrez@gmail.com>
*/
#include <linux/reboot.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <linux/reboot.h>
#include <unistd.h>
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]);