From 09b056975dacd1f0f815ad820b6dc9913b0118a3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 23 Jun 2020 18:55:43 -0400 Subject: fix pointer style to match the style guide We do this in a lot of places, but we're inconsistent. Normalize the code to the Google C++ style guide. Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932 Reviewed-by: Sterling Augustine Reviewed-by: Mark Mentovai --- src/client/mac/handler/breakpad_nlist_64.cc | 77 ++++++++++++++--------------- 1 file changed, 37 insertions(+), 40 deletions(-) (limited to 'src/client/mac/handler/breakpad_nlist_64.cc') diff --git a/src/client/mac/handler/breakpad_nlist_64.cc b/src/client/mac/handler/breakpad_nlist_64.cc index 3492b823..b4f04c91 100644 --- a/src/client/mac/handler/breakpad_nlist_64.cc +++ b/src/client/mac/handler/breakpad_nlist_64.cc @@ -131,7 +131,7 @@ struct MachBits { template int -__breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, +__breakpad_fdnlist(int fd, nlist_type* list, const char** symbolNames, cpu_type_t cpu_type); /* @@ -139,9 +139,9 @@ __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, */ template -int breakpad_nlist_common(const char *name, - nlist_type *list, - const char **symbolNames, +int breakpad_nlist_common(const char* name, + nlist_type* list, + const char** symbolNames, cpu_type_t cpu_type) { int fd = open(name, O_RDONLY, 0); if (fd < 0) @@ -151,16 +151,16 @@ int breakpad_nlist_common(const char *name, return n; } -int breakpad_nlist(const char *name, - struct nlist *list, - const char **symbolNames, +int breakpad_nlist(const char* name, + struct nlist* list, + const char** symbolNames, cpu_type_t cpu_type) { return breakpad_nlist_common(name, list, symbolNames, cpu_type); } -int breakpad_nlist(const char *name, - struct nlist_64 *list, - const char **symbolNames, +int breakpad_nlist(const char* name, + struct nlist_64* list, + const char** symbolNames, cpu_type_t cpu_type) { return breakpad_nlist_common(name, list, symbolNames, cpu_type); } @@ -168,7 +168,7 @@ int breakpad_nlist(const char *name, /* Note: __fdnlist() is called from kvm_nlist in libkvm's kvm.c */ template -int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, +int __breakpad_fdnlist(int fd, nlist_type* list, const char** symbolNames, cpu_type_t cpu_type) { typedef typename MachBits::mach_header_type mach_header_type; typedef typename MachBits::word_type word_type; @@ -189,9 +189,9 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, } struct exec buf; - if (read(fd, (char *)&buf, sizeof(buf)) != sizeof(buf) || - (N_BADMAG(buf) && *((uint32_t *)&buf) != magic && - CFSwapInt32BigToHost(*((uint32_t *)&buf)) != FAT_MAGIC && + if (read(fd, (char*)&buf, sizeof(buf)) != sizeof(buf) || + (N_BADMAG(buf) && *((uint32_t*)&buf) != magic && + CFSwapInt32BigToHost(*((uint32_t*)&buf)) != FAT_MAGIC && /* The following is the big-endian ppc64 check */ (*((uint32_t*)&buf)) != FAT_MAGIC)) { return -1; @@ -199,15 +199,15 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, /* Deal with fat file if necessary */ unsigned arch_offset = 0; - if (CFSwapInt32BigToHost(*((uint32_t *)&buf)) == FAT_MAGIC || + if (CFSwapInt32BigToHost(*((uint32_t*)&buf)) == FAT_MAGIC || /* The following is the big-endian ppc64 check */ - *((unsigned int *)&buf) == FAT_MAGIC) { + *((unsigned int*)&buf) == FAT_MAGIC) { /* Read in the fat header */ struct fat_header fh; if (lseek(fd, 0, SEEK_SET) == -1) { return -1; } - if (read(fd, (char *)&fh, sizeof(fh)) != sizeof(fh)) { + if (read(fd, (char*)&fh, sizeof(fh)) != sizeof(fh)) { return -1; } @@ -215,12 +215,12 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, fh.nfat_arch = CFSwapInt32BigToHost(fh.nfat_arch); /* Read in the fat archs */ - struct fat_arch *fat_archs = - (struct fat_arch *)malloc(fh.nfat_arch * sizeof(struct fat_arch)); + struct fat_arch* fat_archs = + (struct fat_arch*)malloc(fh.nfat_arch * sizeof(struct fat_arch)); if (fat_archs == NULL) { return -1; } - if (read(fd, (char *)fat_archs, + if (read(fd, (char*)fat_archs, sizeof(struct fat_arch) * fh.nfat_arch) != (ssize_t)(sizeof(struct fat_arch) * fh.nfat_arch)) { free(fat_archs); @@ -244,7 +244,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, CFSwapInt32BigToHost(fat_archs[i].align); } - struct fat_arch *fap = NULL; + struct fat_arch* fap = NULL; for (unsigned i = 0; i < fh.nfat_arch; i++) { if (fat_archs[i].cputype == cpu_type) { fap = &fat_archs[i]; @@ -263,7 +263,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, if (lseek(fd, arch_offset, SEEK_SET) == -1) { return -1; } - if (read(fd, (char *)&buf, sizeof(buf)) != sizeof(buf)) { + if (read(fd, (char*)&buf, sizeof(buf)) != sizeof(buf)) { return -1; } } @@ -271,48 +271,45 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, off_t sa; /* symbol address */ off_t ss; /* start of strings */ register_t n; - if (*((unsigned int *)&buf) == magic) { + if (*((unsigned int*)&buf) == magic) { if (lseek(fd, arch_offset, SEEK_SET) == -1) { return -1; } mach_header_type mh; - if (read(fd, (char *)&mh, sizeof(mh)) != sizeof(mh)) { + if (read(fd, (char*)&mh, sizeof(mh)) != sizeof(mh)) { return -1; } - struct load_command *load_commands = - (struct load_command *)malloc(mh.sizeofcmds); + struct load_command* load_commands = + (struct load_command*)malloc(mh.sizeofcmds); if (load_commands == NULL) { return -1; } - if (read(fd, (char *)load_commands, mh.sizeofcmds) != + if (read(fd, (char*)load_commands, mh.sizeofcmds) != (ssize_t)mh.sizeofcmds) { free(load_commands); return -1; } - struct symtab_command *stp = NULL; - struct load_command *lcp = load_commands; + struct symtab_command* stp = NULL; + struct load_command* lcp = load_commands; // iterate through all load commands, looking for // LC_SYMTAB load command for (uint32_t i = 0; i < mh.ncmds; i++) { if (lcp->cmdsize % sizeof(word_type) != 0 || lcp->cmdsize <= 0 || - (char *)lcp + lcp->cmdsize > - (char *)load_commands + mh.sizeofcmds) { + (char*)lcp + lcp->cmdsize > (char*)load_commands + mh.sizeofcmds) { free(load_commands); return -1; } if (lcp->cmd == LC_SYMTAB) { - if (lcp->cmdsize != - sizeof(struct symtab_command)) { + if (lcp->cmdsize != sizeof(struct symtab_command)) { free(load_commands); return -1; } - stp = (struct symtab_command *)lcp; + stp = (struct symtab_command*)lcp; break; } - lcp = (struct load_command *) - ((char *)lcp + lcp->cmdsize); + lcp = (struct load_command*)((char*)lcp + lcp->cmdsize); } if (stp == NULL) { free(load_commands); @@ -347,7 +344,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, if (n < m) m = n; - if (read(fd, (char *)space, m) != m) + if (read(fd, (char*)space, m) != m) break; n -= m; off_t savpos = lseek(fd, 0, SEEK_CUR); @@ -368,13 +365,13 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, if (read(fd, nambuf, maxlen+1) == -1) { return -1; } - const char *s2 = nambuf; - for (nlist_type *p = list; + const char* s2 = nambuf; + for (nlist_type* p = list; symbolNames[p-list] && symbolNames[p-list][0]; p++) { // get the symbol name the user has passed in that // corresponds to the nlist entry that we're looking at - const char *s1 = symbolNames[p - list]; + const char* s1 = symbolNames[p - list]; while (*s1) { if (*s1++ != *s2++) goto cont; -- cgit v1.2.1