Skip to content

Commit

Permalink
Merge pull request #360 from CEED/jed/config-flags
Browse files Browse the repository at this point in the history
Jed/config flags and string processing
  • Loading branch information
jedbrown authored Sep 19, 2019
2 parents fce06f5 + 07a0283 commit a82821c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ build/*
*.DIR
doc/html
ceed.pc
config.mk

# Mac specific
.DS_Store
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ifeq (,$(filter-out undefined default,$(origin LINK)))
LINK = $(CC)
endif
NVCC ?= $(CUDA_DIR)/bin/nvcc
NVCC_CXX ?= $(CXX)

# ASAN must be left empty if you don't want to use it
ASAN ?=
Expand Down Expand Up @@ -544,11 +545,14 @@ print-% :
configure :
@: > config.mk
@echo "CC = $(CC)" | tee -a config.mk
@echo "CXX = $(CXX)" | tee -a config.mk
@echo "FC = $(FC)" | tee -a config.mk
@echo "NVCC = $(NVCC)" | tee -a config.mk
@echo "NVCC_CXX = $(NVCC_CXX)" | tee -a config.mk
@echo "CFLAGS = $(CFLAGS)" | tee -a config.mk
@echo "CPPFLAGS = $(CPPFLAGS)" | tee -a config.mk
@echo "FFLAGS = $(FFLAGS)" | tee -a config.mk
@echo "NVCCFLAGS = $(NVCCFLAGS)" | tee -a config.mk
@echo "LDFLAGS = $(LDFLAGS)" | tee -a config.mk
@echo "LDLIBS = $(LDLIBS)" | tee -a config.mk
@echo "MAGMA_DIR = $(MAGMA_DIR)" | tee -a config.mk
Expand Down
10 changes: 4 additions & 6 deletions backends/occa/ceed-occa-okl.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ int CeedOklPath_Occa(const Ceed ceed, const char *c_src_file,
int ierr;
Ceed_Occa *ceed_data;
ierr = CeedGetData(ceed, (void *)&ceed_data); CeedChk(ierr);
ierr = CeedCalloc(OCCA_PATH_MAX,okl_file); CeedChk(ierr);
memcpy(*okl_file,c_src_file,strlen(c_src_file));
ierr = CeedCalloc(OCCA_PATH_MAX+1, okl_file); CeedChk(ierr);
char *okl = *okl_file;
const char *last_dot = strrchr(okl,'.');
strncpy(okl, c_src_file, OCCA_PATH_MAX);
char *last_dot = strrchr(okl, '.');
if (!last_dot)
return CeedError(ceed, 1, "Cannot find file's extension!");
const size_t okl_path_len = last_dot - okl;
// TODO: Update strncpy to avoid memory corruption
strncpy(&okl[okl_path_len],".okl",5);
strncpy(last_dot, ".okl", OCCA_PATH_MAX - (last_dot - okl));
dbg("[CeedOklPath] Current OKL is %s",okl);
// Test if we can get file's status,
if (stat(okl, &buf)!=0) { // if not revert to occa cache
Expand Down
5 changes: 3 additions & 2 deletions interface/ceed-qfunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vlength,
(*qf)->vlength = vlength;
(*qf)->identity = 0;
(*qf)->function = f;
ierr = CeedCalloc(strlen(source)+1, &source_copy); CeedChk(ierr);
strncpy(source_copy, source, strlen(source));
size_t slen = strlen(source) + 1;
ierr = CeedMalloc(slen, &source_copy); CeedChk(ierr);
memcpy(source_copy, source, slen);
(*qf)->sourcepath = source_copy;
ierr = CeedCalloc(16, &(*qf)->inputfields); CeedChk(ierr);
ierr = CeedCalloc(16, &(*qf)->outputfields); CeedChk(ierr);
Expand Down
8 changes: 3 additions & 5 deletions interface/ceed.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,9 @@ int CeedSetObjectDelegate(Ceed ceed, Ceed delegate, const char *objname) {

// Set object delegate
ceed->objdelegates[count].delegate = delegate;
ierr = CeedCalloc(strlen(objname)+1, &ceed->objdelegates[count].objname);
CeedChk(ierr);
CeedInt len = strlen(ceed->objdelegates[count].objname);
strncpy(ceed->objdelegates[count].objname, objname, len);
ceed->objdelegates[count].objname[len-1] = 0;
size_t slen = strlen(objname) + 1;
ierr = CeedMalloc(slen, &ceed->objdelegates[count].objname); CeedChk(ierr);
memcpy(ceed->objdelegates[count].objname, objname, slen);

// Set delegate parent
delegate->parent = ceed;
Expand Down

0 comments on commit a82821c

Please sign in to comment.