CS 3733 Operating Systems, Fall 1998 Assignment 1 Comments
Assignment 1 notes: Fall 1998
1) Always run lint
2) Do not hard code in sizes
3) Do not do dynamic allocations in declarations;
4) Use setenv to test influence of NEWSDIR environment variable
5) Use strcpy to copy path in convertnews
6) Label the files in your printout
7) char *convertnews(char *newsgroup)
what is sizeof(newsgroup)?
8) What is wrong with the following in lastmod:
if (stat(xxx) == -1) {
fprintf(...);
return -1;
}
9) in convertnews: not allowed to change parameter
10) What is wrong with:
path = (char *)malloc(strlen(ndir)+strlen(npath));
strcpy(path,ndir);
strcat(path,npath);
11) What is wrong with:
char news.g[]="";
...
strcpy(news_g,newsgroup);
12) What is wrong with:
time_t LastMod(char *pathname) {
...
if (pathname == NULL) {
fprintf(stderr,"...");
exit(1);
}
13) What about:
struct stat *StatusReport;
StatusReport = (struct stat *)malloc(sizeof(struct stat));
14) What does the following do:
sleep(*argv[2]);
15) What is wrong with:
path = (char *)malloc(...);
path = newsenv;
16) Inefficient to use strtok and strcat to change . to /
17) In convertnews:
free(newspath);
return newspath;